diff --git a/COMCMS.API/COMCMS.API.csproj b/COMCMS.API/COMCMS.API.csproj index 30903b4..a675440 100644 --- a/COMCMS.API/COMCMS.API.csproj +++ b/COMCMS.API/COMCMS.API.csproj @@ -1,11 +1,18 @@ - + - netcoreapp2.1 + netcoreapp3.1 - + + + + + + + + diff --git a/COMCMS.API/Weixin/Common/MessageFunction.cs b/COMCMS.API/Weixin/Common/MessageFunction.cs new file mode 100644 index 0000000..4b48c51 --- /dev/null +++ b/COMCMS.API/Weixin/Common/MessageFunction.cs @@ -0,0 +1,961 @@ +using COMCMS.Common; +using COMCMS.Core; +using Senparc.CO2NET.Utilities; +using Senparc.NeuChar.Entities; +using Senparc.Weixin.MP; +using Senparc.Weixin.MP.Containers; +using Senparc.Weixin.MP.Entities; +using System; +using System.Collections.Generic; +using System.Text; + +namespace COMCMS.API.Weixin.Common +{ + public class MessageFunction + { + Config siteConfig = Config.GetSystemConfig(); + + #region 处理关注/取消/默认回复方法=========================== + /// + /// 定阅事件的统一处理 + /// + public IResponseMessageBase EventSubscribe(int type, RequestMessageEventBase requestMessage) + { + int accountId = GetAccountId(); //取得公众账户ID + string EventName = ""; + + if (requestMessage.Event.ToString().Trim() != "") + { + EventName = requestMessage.Event.ToString(); + } + //else if (requestMessage.EventKey != null) + //{ + // EventName += requestMessage.EventKey.ToString(); + //} + + + if (!ExistsOriginalId(accountId, requestMessage.ToUserName)) + { + //验证接收方是否为我们系统配置的帐号,即验证微帐号与微信原始帐号id是否一致,如果不一致,说明【1】配置错误,【2】数据来源有问题 + //new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), EventName, "none", "未取到关键词对应的数据", requestMessage.ToUserName); + WeixinResponseContent entity = new WeixinResponseContent() + { + OpenId = requestMessage.FromUserName, + RequestType = requestMessage.MsgType.ToString(), + RequestContent = EventName, + ResponseType = "none", + ReponseContent = "未取到关键词对应的数据", + XmlContent = requestMessage.ToUserName + }; + entity.Insert(); + + + return GetResponseMessageTxtByContent(requestMessage, "验证微帐号与微信原始帐号id不一致,可能原因【1】系统配置错误,【2】非法的数据来源", accountId); + } + + + int responseType = 0, ruleId = 0; + //int ruleId = new BLL.weixin_request_rule().GetRuleIdAndResponseType(accountId, "request_type=" + type, out responseType); + WeixinRequestRule rule = WeixinRequestRule.Find(WeixinRequestRule._.RequestType == type); + + if (rule != null) + { + responseType = rule.ResponseType; + ruleId = rule.Id; + } + + if (ruleId <= 0) + { + + //new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), EventName, "none", "未取到关键词对应的数据", requestMessage.ToUserName); + WeixinResponseContent entity = new WeixinResponseContent() + { + OpenId = requestMessage.FromUserName, + RequestType = requestMessage.MsgType.ToString(), + RequestContent = EventName, + ResponseType = "none", + ReponseContent = "未取到关键词对应的数据", + XmlContent = requestMessage.ToUserName + }; + entity.Insert(); + return null; + } + + IResponseMessageBase reponseMessage = null; + switch (responseType) + { + case (int)WeixinRequestRule.XResponseType.Text: + //发送纯文字 + reponseMessage = GetResponseMessageTxt(requestMessage, rule.Id, accountId); + break; + case (int)WeixinRequestRule.XResponseType.Image: + //发送多图文 + reponseMessage = GetResponseMessageNews(requestMessage, rule.Id, accountId); + break; + case (int)WeixinRequestRule.XResponseType.Voice: + //发送语音 + reponseMessage = GetResponseMessageeMusic(requestMessage, rule.Id, accountId); + break; + case (int)WeixinRequestRule.XResponseType.SingleImage: + reponseMessage = GetResponseMessageSingleImage(requestMessage, rule.Id, accountId); + break; + default: + break; + } + return reponseMessage; + } + #endregion + + #region 请求为文本的处理===================================== + /// + /// 推送纯文字 + /// + public IResponseMessageBase GetResponseMessageTxt(RequestMessageText requestMessage, int ruleId, int accountId) + { + var responseMessage = ResponseMessageBase.CreateFromRequestMessage(requestMessage); + string openid = requestMessage.FromUserName; + string token = ConvertDateTimeInt(DateTime.Now).ToString(); + //responseMessage.Content = new BLL.weixin_request_content().GetContent(ruleId); + WeixinRequestContent ctx = WeixinRequestContent.Find(WeixinRequestContent._.RuleId == ruleId); + if (ctx != null) + { + responseMessage.Content = ctx.Content; + WeixinResponseContent entity = new WeixinResponseContent() + { + OpenId = requestMessage.FromUserName, + RequestType = requestMessage.MsgType.ToString(), + RequestContent = requestMessage.Content, + ResponseType = "text", + ReponseContent = responseMessage.Content, + XmlContent = requestMessage.ToUserName + }; + entity.Insert(); + } + //new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), requestMessage.Content, "text", responseMessage.Content, requestMessage.ToUserName); + return responseMessage; + } + + /// + /// 推送纯文字 + /// + public IResponseMessageBase GetResponseMessageTxtByContent(RequestMessageText requestMessage, string content, int accountId) + { + var responseMessage = ResponseMessageBase.CreateFromRequestMessage(requestMessage); + responseMessage.Content = content; + WeixinResponseContent entity = new WeixinResponseContent() + { + OpenId = requestMessage.FromUserName, + RequestType = requestMessage.MsgType.ToString(), + RequestContent = requestMessage.Content, + ResponseType = "text", + ReponseContent = "文字请求,推送纯粹文字,内容为:" + content, + XmlContent = requestMessage.ToUserName + }; + entity.Insert(); + //new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), requestMessage.Content, "text", "文字请求,推送纯粹文字,内容为:" + content, requestMessage.ToUserName); + return responseMessage; + } + + /// + /// 处理语音请求 + /// + public IResponseMessageBase GetResponseMessageeMusic(RequestMessageText requestMessage, int ruleId, int accountId) + { + //string EventName = ""; + var responseMessage = ResponseMessageBase.CreateFromRequestMessage(requestMessage); + //Model.weixin_request_content model = new BLL.weixin_request_content().GetModel(ruleId); + WeixinRequestContent model = WeixinRequestContent.Find(WeixinRequestContent._.RuleId == ruleId); + if (model == null) + { + //new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), EventName, "music", "-1", requestMessage.ToUserName); + WeixinResponseContent entity = new WeixinResponseContent() + { + OpenId = requestMessage.FromUserName, + RequestType = requestMessage.MsgType.ToString(), + RequestContent = requestMessage.Content, + ResponseType = "music", + ReponseContent = "-1", + XmlContent = requestMessage.ToUserName + }; + entity.Insert(); + } + else + { + if (model.MediaURL.Contains("http://")) + { + responseMessage.Music.MusicUrl = model.MediaURL; + + } + else + { + //因为安装目录是以/开头,所以去掉,以免出现双斜杆 + responseMessage.Music.MusicUrl = Utils.GetServerUrl() + model.MediaURL; + } + responseMessage.Music.Title = model.Title; + responseMessage.Music.Description = model.Content; + //new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), EventName, "music", "音乐链接:" + model.media_url + "|标题:" + model.title + "|描述:" + model.content, requestMessage.ToUserName); + WeixinResponseContent entity = new WeixinResponseContent() + { + OpenId = requestMessage.FromUserName, + RequestType = requestMessage.MsgType.ToString(), + RequestContent = requestMessage.Content, + ResponseType = "music", + ReponseContent = "音乐链接:" + model.MediaURL + "|标题:" + model.Title + "|描述:" + model.Content, + XmlContent = requestMessage.ToUserName + }; + entity.Insert(); + } + return responseMessage; + } + + /// + /// 推送多图文 + /// + public IResponseMessageBase GetResponseMessageNews(RequestMessageText requestMessage, int ruleId, int accountId) + { + var responseMessage = ResponseMessageBase.CreateFromRequestMessage(requestMessage); + string openid = requestMessage.FromUserName; + string token = ConvertDateTimeInt(DateTime.Now).ToString(); + + Senparc.NeuChar.Entities.Article article; + List artList = new List(); + IList twList = WeixinRequestContent.FindAll(WeixinRequestContent._.RuleId == ruleId, null, null, 0, 10); + foreach (WeixinRequestContent modelt in twList) + { + article = new Senparc.NeuChar.Entities.Article(); + article.Title = modelt.Title; + article.Description = modelt.Content; + article.Url = GetWXApiUrl(modelt.LinkUrl, token, openid); + if (string.IsNullOrEmpty(modelt.ImgURL)) + article.PicUrl = string.Empty; + else + { + if (modelt.ImgURL.Contains("http://")) + { + article.PicUrl = modelt.ImgURL; + + } + else + { + //因为安装目录是以/开头,所以去掉,以免出现双斜杆 + article.PicUrl = Utils.GetServerUrl() + "/" + modelt.ImgURL; + } + } + artList.Add(article); + } + if (artList.Count == 0) + { + WeixinResponseContent entity = new WeixinResponseContent() + { + OpenId = requestMessage.FromUserName, + RequestType = requestMessage.MsgType.ToString(), + RequestContent = requestMessage.Content, + ResponseType = "txtpic", + ReponseContent = "-1", + XmlContent = requestMessage.ToUserName + }; + entity.Insert(); + //new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), requestMessage.Content, "txtpic", "-1", requestMessage.ToUserName); + } + else + { + WeixinResponseContent entity = new WeixinResponseContent() + { + OpenId = requestMessage.FromUserName, + RequestType = requestMessage.MsgType.ToString(), + RequestContent = requestMessage.Content, + ResponseType = "txtpic", + ReponseContent = "这次发了" + artList.Count + "条图文", + XmlContent = requestMessage.ToUserName + }; + entity.Insert(); + //new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), requestMessage.Content, "txtpic", "这次发了" + artList.Count + "条图文", requestMessage.ToUserName); + } + responseMessage.Articles.AddRange(artList); + + //Article article; + //List
artList = new List
(); + //IList twList = new BLL.weixin_request_content().GetModelList(10, ruleId, string.Empty); + //foreach (Model.weixin_request_content modelt in twList) + //{ + // article = new Article(); + // article.Title = modelt.title; + // article.Description = modelt.content; + // article.Url = GetWXApiUrl(modelt.link_url, token, openid); + // if (string.IsNullOrEmpty(modelt.img_url)) + // { + // article.PicUrl = string.Empty; + // } + // else + // { + // if (modelt.img_url.Contains("http://")) + // { + // article.PicUrl = modelt.img_url; + + // } + // else + // { + // //因为安装目录是以/开头,所以去掉,以免出现双斜杆 + // article.PicUrl = siteConfig.weburl + "/" + siteConfig.webpath.Replace("/", "") + modelt.img_url; + // } + // } + // artList.Add(article); + //} + + //if (artList.Count == 0) + //{ + // new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), requestMessage.Content, "txtpic", "-1", requestMessage.ToUserName); + //} + //else + //{ + // new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), requestMessage.Content, "txtpic", "这次发了" + artList.Count + "条图文", requestMessage.ToUserName); + //} + //responseMessage.Articles.AddRange(artList); + return responseMessage; + } + + + #endregion + + #region 请求为图片的处理===================================== + /// + /// 推送纯文字 + /// + public IResponseMessageBase GetResponseMessageTxt(RequestMessageImage requestMessage, int ruleId, int accountId) + { + var responseMessage = ResponseMessageBase.CreateFromRequestMessage(requestMessage); + string openid = requestMessage.FromUserName; + string token = ConvertDateTimeInt(DateTime.Now).ToString(); + //responseMessage.Content = new BLL.weixin_request_content().GetContent(ruleId); + WeixinRequestContent ctx = WeixinRequestContent.Find(WeixinRequestContent._.RuleId == ruleId); + if (ctx != null) + { + responseMessage.Content = ctx.Content; + WeixinResponseContent entity = new WeixinResponseContent() + { + OpenId = requestMessage.FromUserName, + RequestType = requestMessage.MsgType.ToString(), + RequestContent = requestMessage.PicUrl, + ResponseType = "text", + ReponseContent = responseMessage.Content, + XmlContent = requestMessage.ToUserName + }; + entity.Insert(); + } + return responseMessage; + } + /// + /// 推送纯文字 + /// + public IResponseMessageBase GetResponseMessageTxtByContent(RequestMessageImage requestMessage, string content, int accountId) + { + var responseMessage = ResponseMessageBase.CreateFromRequestMessage(requestMessage); + responseMessage.Content = content; + WeixinResponseContent entity = new WeixinResponseContent() + { + OpenId = requestMessage.FromUserName, + RequestType = requestMessage.MsgType.ToString(), + RequestContent = requestMessage.PicUrl, + ResponseType = "text", + ReponseContent = "文字请求,推送纯粹文字,内容为:" + content, + XmlContent = requestMessage.ToUserName + }; + entity.Insert(); + //new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), requestMessage.Content, "text", "文字请求,推送纯粹文字,内容为:" + content, requestMessage.ToUserName); + return responseMessage; + } + + /// + /// 处理语音请求 + /// + public IResponseMessageBase GetResponseMessageeMusic(RequestMessageImage requestMessage, int ruleId, int accountId) + { + //string EventName = ""; + var responseMessage = ResponseMessageBase.CreateFromRequestMessage(requestMessage); + //Model.weixin_request_content model = new BLL.weixin_request_content().GetModel(ruleId); + WeixinRequestContent model = WeixinRequestContent.Find(WeixinRequestContent._.RuleId == ruleId); + if (model == null) + { + //new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), EventName, "music", "-1", requestMessage.ToUserName); + WeixinResponseContent entity = new WeixinResponseContent() + { + OpenId = requestMessage.FromUserName, + RequestType = requestMessage.MsgType.ToString(), + RequestContent = requestMessage.PicUrl, + ResponseType = "music", + ReponseContent = "-1", + XmlContent = requestMessage.ToUserName + }; + entity.Insert(); + } + else + { + if (model.MediaURL.Contains("http://")) + { + responseMessage.Music.MusicUrl = model.MediaURL; + + } + else + { + //因为安装目录是以/开头,所以去掉,以免出现双斜杆 + responseMessage.Music.MusicUrl = Utils.GetServerUrl() + model.MediaURL; + } + responseMessage.Music.Title = model.Title; + responseMessage.Music.Description = model.Content; + //new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), EventName, "music", "音乐链接:" + model.media_url + "|标题:" + model.title + "|描述:" + model.content, requestMessage.ToUserName); + WeixinResponseContent entity = new WeixinResponseContent() + { + OpenId = requestMessage.FromUserName, + RequestType = requestMessage.MsgType.ToString(), + RequestContent = requestMessage.PicUrl, + ResponseType = "music", + ReponseContent = "音乐链接:" + model.MediaURL + "|标题:" + model.Title + "|描述:" + model.Content, + XmlContent = requestMessage.ToUserName + }; + entity.Insert(); + } + return responseMessage; + } + + /// + /// 推送多图文 + /// + public IResponseMessageBase GetResponseMessageNews(RequestMessageImage requestMessage, int ruleId, int accountId) + { + var responseMessage = ResponseMessageBase.CreateFromRequestMessage(requestMessage); + string openid = requestMessage.FromUserName; + string token = ConvertDateTimeInt(DateTime.Now).ToString(); + + Senparc.NeuChar.Entities.Article article; + List artList = new List(); + IList twList = WeixinRequestContent.FindAll(WeixinRequestContent._.RuleId == ruleId, null, null, 0, 10); + foreach (WeixinRequestContent modelt in twList) + { + article = new Senparc.NeuChar.Entities.Article(); + article.Title = modelt.Title; + article.Description = modelt.Content; + article.Url = GetWXApiUrl(modelt.LinkUrl, token, openid); + if (string.IsNullOrEmpty(modelt.ImgURL)) + article.PicUrl = string.Empty; + else + { + if (modelt.ImgURL.Contains("http://")) + { + article.PicUrl = modelt.ImgURL; + + } + else + { + //因为安装目录是以/开头,所以去掉,以免出现双斜杆 + article.PicUrl = Utils.GetServerUrl() + "/" + modelt.ImgURL; + } + } + artList.Add(article); + } + if (artList.Count == 0) + { + WeixinResponseContent entity = new WeixinResponseContent() + { + OpenId = requestMessage.FromUserName, + RequestType = requestMessage.MsgType.ToString(), + RequestContent = requestMessage.PicUrl, + ResponseType = "txtpic", + ReponseContent = "-1", + XmlContent = requestMessage.ToUserName + }; + entity.Insert(); + //new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), requestMessage.Content, "txtpic", "-1", requestMessage.ToUserName); + } + else + { + WeixinResponseContent entity = new WeixinResponseContent() + { + OpenId = requestMessage.FromUserName, + RequestType = requestMessage.MsgType.ToString(), + RequestContent = requestMessage.PicUrl, + ResponseType = "txtpic", + ReponseContent = "这次发了" + artList.Count + "条图文", + XmlContent = requestMessage.ToUserName + }; + entity.Insert(); + //new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), requestMessage.Content, "txtpic", "这次发了" + artList.Count + "条图文", requestMessage.ToUserName); + } + responseMessage.Articles.AddRange(artList); + + return responseMessage; + } + + /// + /// 推送单张图片 + /// + public IResponseMessageBase GetResponseMessageSingleImagesContent(RequestMessageText requestMessage, int ruleId, int accountId) + { + var responseMessage = ResponseMessageBase.CreateFromRequestMessage(requestMessage); + string EventName = ""; + var locationService = new LocationService(); + NewLife.Log.XTrace.WriteLine("相应单图片回复"); + WeixinRequestContent model = WeixinRequestContent.Find(WeixinRequestContent._.RuleId == ruleId); + if (model == null) + { + NewLife.Log.XTrace.WriteLine("没找到单图片回复规则"); + //new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), EventName, "music", "-1", requestMessage.ToUserName); + WeixinResponseContent entity = new WeixinResponseContent() + { + OpenId = requestMessage.FromUserName, + RequestType = requestMessage.MsgType.ToString(), + RequestContent = EventName, + ResponseType = "image", + ReponseContent = "-1", + XmlContent = requestMessage.ToUserName + }; + entity.Insert(); + } + else + { + if (string.IsNullOrEmpty(model.MediaURL)) + { + //如果没有mediaid 则先上传 + string imgUrl = "~/wwwroot" + model.ImgURL; + var uploadResult = Senparc.Weixin.MP.AdvancedAPIs.MediaApi.UploadTemporaryMedia(siteConfig.AppId, UploadMediaFileType.image, + ServerUtility.ContentRootMapPath(imgUrl)); + //NewLife.Log.XTrace.WriteLine("准备上传素材,imgurl:" + imgurl); + + //var accessToken = AccessTokenContainer.TryGetAccessToken(siteConfig.AppId, siteConfig.AppSecret);// AccessTokenContainer.TryGetAccessToken(official.AppId, official.AppSecret, false); + //上传图片素材 imgurl 必须是本地绝对路径。。。。 + //var upresult = Senparc.Weixin.MP.AdvancedAPIs.MediaApi.UploadForeverMedia(accessToken, imgurl); + model.MediaURL = uploadResult.media_id; + model.Update(); + NewLife.Log.XTrace.WriteLine("上传素材,返回mediaid:" + uploadResult.media_id); + } + Image img = new Image(); + img.MediaId = model.MediaURL; + responseMessage.CreateTime = DateTime.Now; + responseMessage.Image = img; + + NewLife.Log.XTrace.WriteLine("回复单图片,mediaid" + img.MediaId + ";回复用户openid:" + responseMessage.FromUserName); + + WeixinResponseContent entity = new WeixinResponseContent() + { + OpenId = requestMessage.FromUserName, + RequestType = requestMessage.MsgType.ToString(), + RequestContent = EventName, + ResponseType = "image", + ReponseContent = "图片:" + model.MediaURL + "|标题:" + model.Title, + XmlContent = requestMessage.ToUserName + }; + entity.Insert(); + } + + return responseMessage; + } + + #endregion + + #region 请求为事件的处理===================================== + /// + /// 推送纯文字 + /// + public IResponseMessageBase GetResponseMessageTxt(RequestMessageEventBase requestMessage, int ruleId, int accountId) + { + var responseMessage = ResponseMessageBase.CreateFromRequestMessage(requestMessage); + string openid = requestMessage.FromUserName; + string token = ConvertDateTimeInt(DateTime.Now).ToString(); + WeixinRequestContent rct = WeixinRequestContent.Find(WeixinRequestContent._.RuleId == ruleId); + responseMessage.Content = rct != null ? rct.Content : "";// new BLL.weixin_request_content().GetContent(ruleId); + + NewLife.Log.XTrace.WriteLine("文本自动关注回复:" + ruleId + "||" + responseMessage.Content); + + string EventName = ""; + if (requestMessage.Event.ToString().Trim() != "") + { + EventName = requestMessage.Event.ToString(); + } + //else if (requestMessage.EventKey != null) + //{ + // EventName += requestMessage.EventKey.ToString(); + //} + + //new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), EventName, "text", responseMessage.Content, requestMessage.ToUserName); + WeixinResponseContent entity = new WeixinResponseContent() + { + OpenId = requestMessage.FromUserName, + RequestType = requestMessage.MsgType.ToString(), + RequestContent = EventName, + ResponseType = "text", + ReponseContent = responseMessage.Content, + XmlContent = requestMessage.ToUserName + }; + entity.Insert(); + + return responseMessage; + } + + /// + /// 推送纯文字 + /// + public IResponseMessageBase GetResponseMessageTxtByContent(RequestMessageEventBase requestMessage, string content, int accountId) + { + var responseMessage = ResponseMessageBase.CreateFromRequestMessage(requestMessage); + var locationService = new LocationService(); + responseMessage.Content = content; + string EventName = ""; + if (requestMessage.Event.ToString().Trim() != "") + { + EventName = requestMessage.Event.ToString(); + } + //else if (requestMessage.EventKey != null) + //{ + // EventName += requestMessage.EventKey.ToString(); + //} + //new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), EventName, "text", "事件:推送纯粹的文字,内容为:" + content, requestMessage.ToUserName); + WeixinResponseContent entity = new WeixinResponseContent() + { + OpenId = requestMessage.FromUserName, + RequestType = requestMessage.MsgType.ToString(), + RequestContent = EventName, + ResponseType = "text", + ReponseContent = "事件:推送纯粹的文字,内容为:" + content, + XmlContent = requestMessage.ToUserName + }; + entity.Insert(); + return responseMessage; + } + + + /// + /// 推送纯文字 + /// + public IResponseMessageBase GetResponseMessageSingleImage(RequestMessageEventBase requestMessage, int ruleId, int accountId) + { + var responseMessage = ResponseMessageBase.CreateFromRequestMessage(requestMessage); + string openid = requestMessage.FromUserName; + string token = ConvertDateTimeInt(DateTime.Now).ToString(); + + NewLife.Log.XTrace.WriteLine("相应单图片回复"); + WeixinRequestContent model = WeixinRequestContent.Find(WeixinRequestContent._.RuleId == ruleId); + if (model == null) + { + NewLife.Log.XTrace.WriteLine("没找到单图片回复规则"); + //new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), EventName, "music", "-1", requestMessage.ToUserName); + WeixinResponseContent entity = new WeixinResponseContent() + { + OpenId = requestMessage.FromUserName, + RequestType = requestMessage.MsgType.ToString(), + RequestContent = "关注自动回复", + ResponseType = "image", + ReponseContent = "-1", + XmlContent = requestMessage.ToUserName + }; + entity.Insert(); + } + else + { + if (string.IsNullOrEmpty(model.MediaURL)) + { + string imgUrl = "~/wwwroot" + model.ImgURL; + var uploadResult = Senparc.Weixin.MP.AdvancedAPIs.MediaApi.UploadTemporaryMedia(siteConfig.AppId, UploadMediaFileType.image, + ServerUtility.ContentRootMapPath(imgUrl)); + + model.MediaURL = uploadResult.media_id; + model.Update(); + NewLife.Log.XTrace.WriteLine("上传素材,返回mediaid:" + uploadResult.media_id); + } + Image img = new Image(); + img.MediaId = model.MediaURL; + responseMessage.CreateTime = DateTime.Now; + responseMessage.Image = img; + + NewLife.Log.XTrace.WriteLine("回复单图片,mediaid" + img.MediaId + ";回复用户openid:" + responseMessage.FromUserName); + + WeixinResponseContent entity = new WeixinResponseContent() + { + OpenId = requestMessage.FromUserName, + RequestType = requestMessage.MsgType.ToString(), + RequestContent = "关注自动回复", + ResponseType = "image", + ReponseContent = "图片:" + model.MediaURL + "|标题:" + model.Title, + XmlContent = requestMessage.ToUserName + }; + entity.Insert(); + } + + return responseMessage; + } + + /// + /// 推送单张图片 + /// + public IResponseMessageBase GetResponseMessageSingleImagesContent(RequestMessageEventBase requestMessage, int ruleId, int accountId) + { + var responseMessage = ResponseMessageBase.CreateFromRequestMessage(requestMessage); + string EventName = ""; + var locationService = new LocationService(); + NewLife.Log.XTrace.WriteLine("相应单图片回复"); + WeixinRequestContent model = WeixinRequestContent.Find(WeixinRequestContent._.RuleId == ruleId); + if (model == null) + { + NewLife.Log.XTrace.WriteLine("没找到单图片回复规则"); + //new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), EventName, "music", "-1", requestMessage.ToUserName); + WeixinResponseContent entity = new WeixinResponseContent() + { + OpenId = requestMessage.FromUserName, + RequestType = requestMessage.MsgType.ToString(), + RequestContent = EventName, + ResponseType = "image", + ReponseContent = "-1", + XmlContent = requestMessage.ToUserName + }; + entity.Insert(); + } + else + { + if (string.IsNullOrEmpty(model.MediaURL)) + { + //如果没有mediaid 则先上传 + string imgUrl = "~/wwwroot" + model.ImgURL; + var uploadResult = Senparc.Weixin.MP.AdvancedAPIs.MediaApi.UploadTemporaryMedia(siteConfig.AppId, UploadMediaFileType.image, + ServerUtility.ContentRootMapPath(imgUrl)); + model.MediaURL = uploadResult.media_id; + model.Update(); + NewLife.Log.XTrace.WriteLine("上传素材,返回mediaid:" + uploadResult.media_id); + } + Image img = new Image(); + img.MediaId = model.MediaURL; + responseMessage.CreateTime = DateTime.Now; + responseMessage.Image = img; + + NewLife.Log.XTrace.WriteLine("回复单图片,mediaid" + img.MediaId + ";回复用户openid:" + responseMessage.FromUserName); + + WeixinResponseContent entity = new WeixinResponseContent() + { + OpenId = requestMessage.FromUserName, + RequestType = requestMessage.MsgType.ToString(), + RequestContent = EventName, + ResponseType = "image", + ReponseContent = "图片:" + model.MediaURL + "|标题:" + model.Title, + XmlContent = requestMessage.ToUserName + }; + entity.Insert(); + } + + return responseMessage; + } + + /// + /// 处理语音请求 + /// + public IResponseMessageBase GetResponseMessageeMusic(RequestMessageEventBase requestMessage, int ruleId, int accountId) + { + var responseMessage = ResponseMessageBase.CreateFromRequestMessage(requestMessage); + string EventName = ""; + if (requestMessage.Event.ToString().Trim() != "") + { + EventName = requestMessage.Event.ToString(); + } + //else if (requestMessage.EventKey != null) + //{ + // EventName += requestMessage.EventKey.ToString(); + //} + + //Model.weixin_request_content model = new BLL.weixin_request_content().GetModel(ruleId); + WeixinRequestContent model = WeixinRequestContent.Find(WeixinRequestContent._.RuleId == ruleId); + if (model == null) + { + + //new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), EventName, "music", "-1", requestMessage.ToUserName); + WeixinResponseContent entity = new WeixinResponseContent() + { + OpenId = requestMessage.FromUserName, + RequestType = requestMessage.MsgType.ToString(), + RequestContent = EventName, + ResponseType = "music", + ReponseContent = "-1", + XmlContent = requestMessage.ToUserName + }; + entity.Insert(); + } + else + { + if (model.MediaURL.Contains("http://")) + { + responseMessage.Music.MusicUrl = model.MediaURL; + + } + else + { + //因为安装目录是以/开头,所以去掉,以免出现双斜杆 + responseMessage.Music.MusicUrl = Utils.GetServerUrl() + model.MediaURL; + } + responseMessage.Music.Title = model.Title; + responseMessage.Music.Description = model.Content; + //new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), EventName, "music", "音乐链接:" + model.media_url + "|标题:" + model.title + "|描述:" + model.content, requestMessage.ToUserName); + WeixinResponseContent entity = new WeixinResponseContent() + { + OpenId = requestMessage.FromUserName, + RequestType = requestMessage.MsgType.ToString(), + RequestContent = EventName, + ResponseType = "music", + ReponseContent = "音乐链接:" + model.MediaURL + "|标题:" + model.Title + "|描述:" + model.Content, + XmlContent = requestMessage.ToUserName + }; + entity.Insert(); + } + return responseMessage; + } + + /// + /// 推送多图文 + /// + public IResponseMessageBase GetResponseMessageNews(RequestMessageEventBase requestMessage, int ruleId, int accountId) + { + var responseMessage = ResponseMessageBase.CreateFromRequestMessage(requestMessage); + string openid = requestMessage.FromUserName; + string token = ConvertDateTimeInt(DateTime.Now).ToString(); + + Senparc.NeuChar.Entities.Article article; + List artList = new List(); + //IList twList = new BLL.weixin_request_content().GetModelList(10, ruleId, string.Empty); + IList twList = WeixinRequestContent.FindAll(WeixinRequestContent._.RuleId == ruleId, null, null, 0, 10); + foreach (WeixinRequestContent modelt in twList) + { + article = new Senparc.NeuChar.Entities.Article(); + article.Title = modelt.Title; + article.Description = modelt.Content; + article.Url = GetWXApiUrl(modelt.LinkUrl, token, openid); + if (string.IsNullOrEmpty(modelt.ImgURL)) + { + article.PicUrl = string.Empty; + } + else + { + if (modelt.ImgURL.Contains("http://")) + { + article.PicUrl = modelt.ImgURL; + + } + else + { + //因为安装目录是以/开头,所以去掉,以免出现双斜杆 + article.PicUrl = Utils.GetServerUrl() + modelt.ImgURL; + } + } + artList.Add(article); + } + + string EventName = ""; + if (requestMessage.Event.ToString().Trim() != "") + { + EventName = requestMessage.Event.ToString(); + } + //else if (requestMessage.EventKey != null) + //{ + // EventName += requestMessage.EventKey.ToString(); + //} + + if (artList.Count == 0) + { + //new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), EventName, "txtpic", "-1", requestMessage.ToUserName); + WeixinResponseContent entity = new WeixinResponseContent() + { + OpenId = requestMessage.FromUserName, + RequestType = requestMessage.MsgType.ToString(), + RequestContent = EventName, + ResponseType = "txtpic", + ReponseContent = "-1", + XmlContent = requestMessage.ToUserName + }; + entity.Insert(); + } + else + { + //new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), EventName, "txtpic", "这次发了" + artList.Count + "条图文", requestMessage.ToUserName); + WeixinResponseContent entity = new WeixinResponseContent() + { + OpenId = requestMessage.FromUserName, + RequestType = requestMessage.MsgType.ToString(), + RequestContent = EventName, + ResponseType = "txtpic", + ReponseContent = "这次发了" + artList.Count + "条图文", + XmlContent = requestMessage.ToUserName + }; + entity.Insert(); + } + responseMessage.Articles.AddRange(artList); + return responseMessage; + } + #endregion + + #region 获取验证公众账户ID=================================== + /// + /// 获取公众账户的ID + /// + public int GetAccountId() + { + if (string.IsNullOrEmpty(MyHttpContext.Current.Request.Query["uid"])) + { + return 0; + } + int tmpInt = 0; + if (!int.TryParse(MyHttpContext.Current.Request.Query["uid"].ToString(), out tmpInt)) + { + return 0; + } + int uid = int.Parse(MyHttpContext.Current.Request.Query["uid"].ToString()); + return uid; + } + + /// + /// 验证公众账户原始ID是否一致 + /// + public bool ExistsOriginalId(int accountId, string originalId) + { + //if(siteConfig.WexinAccount == ) + //if (WechatOfficial.FindCount(WechatOfficial._.Id == accountId & WechatOfficial._.OriginalId == originalId, null, null, 0, 0) > 0) + //{ + // return true; + //} + //else + //{ + // return false; + //} + return true; + //return new BLL.weixin_account().ExistsOriginalId(accountId, originalId); + } + #endregion + + #region 常用的方法封装======================================= + /// + /// 拼接微信URL地址参数 + /// + public string GetWXApiUrl(string url, string token, string openid) + { + if (url.Contains("?")) + { + return url + "&token=" + token + "&openid=" + openid; + } + return url + "?token=" + token + "&openid=" + openid; + } + + /// + /// 设置微信url地址的后缀 + /// + /// + public string GetWxUrlSuffix() + { + return "wxref=mp.weixin.qq.com"; + } + + /// + /// DateTime时间格式转换为Unix时间戳格式 + /// + public long ConvertDateTimeInt(System.DateTime time) + { + //long intResult = 0; + + //System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); + //intResult = (long)(time - startTime).TotalSeconds; + return long.Parse(Utils.GetTimeStamp()); + } + #endregion + } +} diff --git a/COMCMS.API/Weixin/CustomMessageHandler/CustomMessageContext.cs b/COMCMS.API/Weixin/CustomMessageHandler/CustomMessageContext.cs new file mode 100644 index 0000000..9cb7d6d --- /dev/null +++ b/COMCMS.API/Weixin/CustomMessageHandler/CustomMessageContext.cs @@ -0,0 +1,41 @@ +using Senparc.NeuChar.Context; +using Senparc.NeuChar.Entities; +using System; +using System.Collections.Generic; +using System.Text; +using Senparc.Weixin.MP.Entities; +using Senparc.Weixin.MP.MessageContexts; + +namespace COMCMS.API.Weixin.CustomMessageHandler +{ + public class CustomMessageContext : DefaultMpMessageContext + { + public CustomMessageContext() + { + base.MessageContextRemoved += CustomMessageContext_MessageContextRemoved; + } + + /// + /// 当上下文过期,被移除时触发的时间 + /// + /// + /// + void CustomMessageContext_MessageContextRemoved(object sender, WeixinContextRemovedEventArgs e) + { + /* 注意,这个事件不是实时触发的(当然你也可以专门写一个线程监控) + * 为了提高效率,根据WeixinContext中的算法,这里的过期消息会在过期后下一条请求执行之前被清除 + */ + + var messageContext = e.MessageContext as CustomMessageContext; + if (messageContext == null) + { + return;//如果是正常的调用,messageContext不会为null + } + + //TODO:这里根据需要执行消息过期时候的逻辑,下面的代码仅供参考 + + //Log.InfoFormat("{0}的消息上下文已过期",e.OpenId); + //api.SendMessage(e.OpenId, "由于长时间未搭理客服,您的客服状态已退出!"); + } + } +} diff --git a/COMCMS.API/Weixin/CustomMessageHandler/CustomMessageHandler.cs b/COMCMS.API/Weixin/CustomMessageHandler/CustomMessageHandler.cs new file mode 100644 index 0000000..6d45d8a --- /dev/null +++ b/COMCMS.API/Weixin/CustomMessageHandler/CustomMessageHandler.cs @@ -0,0 +1,398 @@ +using Senparc.Weixin.MP.MessageHandlers; +using System; +using System.Collections.Generic; +using System.Text; +using COMCMS.Core; +using System.IO; +using Senparc.Weixin.MP.Entities.Request; +using Senparc.Weixin.MP.Entities; +using Senparc.NeuChar.Entities; +using System.Threading.Tasks; +using Senparc.NeuChar.Entities.Request; +using System.Linq; +using Senparc.Weixin.MP.AdvancedAPIs; +using Senparc.CO2NET.Utilities; +using Senparc.Weixin.MP; +using NewLife.Log; +using Senparc.NeuChar.Helpers; + +namespace COMCMS.API.Weixin.CustomMessageHandler +{ + /// + /// 自定义MessageHandler + /// 把MessageHandler作为基类,重写对应请求的处理方法 + /// + public partial class CustomMessageHandler : MessageHandler /*如果不需要自定义,可以直接使用: + MessageHandler */ + { + private Config cfg = Config.GetSystemConfig(); + /// + /// 模板消息集合(Key:checkCode,Value:OpenId) + /// 注意:这里只做测试,只适用于单服务器 + /// + public static Dictionary TemplateMessageCollection = new Dictionary(); + + private string appId = ""; + /// + /// 为中间件提供生成当前类的委托 + /// + public static Func GenerateMessageHandler = (stream, postModel, maxRecordCount) + => new CustomMessageHandler(stream, postModel, maxRecordCount, false /* 是否只允许处理加密消息,以提高安全性 */); + public CustomMessageHandler(Stream inputStream, PostModel postModel, int maxRecordCount = 0, bool onlyAllowEcryptMessage = false) + : base(inputStream, postModel, maxRecordCount, onlyAllowEcryptMessage) + { + //这里设置仅用于测试,实际开发可以在外部更全局的地方设置, + //比如MessageHandler.GlobalGlobalMessageContext.ExpireMinutes = 3。 + GlobalMessageContext.ExpireMinutes = 3; + + OnlyAllowEcryptMessage = true;//是否只允许接收加密消息,默认为 false + + if (!string.IsNullOrEmpty(postModel.AppId)) + { + appId = postModel.AppId;//通过第三方开放平台发送过来的请求 + } + else + appId = cfg.AppId; + + //在指定条件下,不使用消息去重 + base.OmitRepeatedMessageFunc = requestMessage => + { + var textRequestMessage = requestMessage as RequestMessageText; + if (textRequestMessage != null && textRequestMessage.Content == "容错") + { + return false; + } + return true; + }; + } + + public override IResponseMessageBase DefaultResponseMessage(IRequestMessageBase requestMessage) + { + /* 所有没有被处理的消息会默认返回这里的结果, + * 因此,如果想把整个微信请求委托出去(例如需要使用分布式或从其他服务器获取请求), + * 只需要在这里统一发出委托请求,如: + * var responseMessage = MessageAgent.RequestResponseMessage(agentUrl, agentToken, RequestDocument.ToString()); + * return responseMessage; + */ + + var responseMessage = this.CreateResponseMessage(); + responseMessage.Content = "这条消息来自DefaultResponseMessage。"; + return responseMessage; + } + + /// + /// 处理文字请求 + /// + /// 请求消息 + /// + public override async Task OnTextRequestAsync(RequestMessageText requestMessage) + { + var defaultResponseMessage = base.CreateResponseMessage(); + IResponseMessageBase IR = null; + Common.MessageFunction cmfun = new Common.MessageFunction(); + int ruleId = 0; + + var requestHandler = await requestMessage.StartHandler().Default(async () => + { + string keywords = requestMessage.Content; + if (!string.IsNullOrEmpty(keywords)) keywords = keywords.Trim(); + + var currentMessageContext = await base.GetCurrentMessageContext(); + + //先精确匹配,再模糊匹配 + Core.WeixinRequestRule rule = Core.WeixinRequestRule.Find(Core.WeixinRequestRule._.Keywords == keywords & Core.WeixinRequestRule._.RequestType == (int)Core.WeixinRequestRule.XRequestType.Text); + + if (rule == null) + { + //模糊匹配 + IList listRule = Core.WeixinRequestRule.FindAll(Core.WeixinRequestRule._.RequestType == (int)Core.WeixinRequestRule.XRequestType.Text & Core.WeixinRequestRule._.IsLikeQuery == 1, null, null, 0, 0); + if (listRule != null && listRule.Count > 0) + { + int lenKeyword = keywords.Length; + foreach (var item in listRule) + { + if (lenKeyword >= item.Keywords.Length && keywords.IndexOf(item.Keywords) >= 0) + { + rule = item;//规则 + break; + } + } + } + } + if (rule == null) + { + Core.WeixinRequestRule notFindKeywordRule = Core.WeixinRequestRule.Find(Core.WeixinRequestRule._.RequestType == (int)Core.WeixinRequestRule.XRequestType.NotFindKeyword); + if (notFindKeywordRule == null) + { + //找不到规则 + Core.WeixinResponseContent entity = new Core.WeixinResponseContent() + { + OpenId = requestMessage.FromUserName, + RequestType = requestMessage.MsgType.ToString(), + RequestContent = requestMessage.Content, + ResponseType = "none", + ReponseContent = "未取到关键词对应的数据", + XmlContent = requestMessage.ToUserName + }; + entity.Insert(); + return cmfun.GetResponseMessageTxtByContent(requestMessage, "未找到匹配的关键词", 0); + } + else + { + ruleId = notFindKeywordRule.Id; + switch (notFindKeywordRule.ResponseType) + { + case (int)Core.WeixinRequestRule.XResponseType.Text: + //发送纯文字 + IR = cmfun.GetResponseMessageTxt(requestMessage, ruleId, 0); + break; + case (int)Core.WeixinRequestRule.XResponseType.Image: + //发送多图文 + IR = cmfun.GetResponseMessageNews(requestMessage, ruleId, 0); + break; + case (int)Core.WeixinRequestRule.XResponseType.Voice: + //发送语音 + IR = cmfun.GetResponseMessageeMusic(requestMessage, ruleId, 0); + break; + case (int)Core.WeixinRequestRule.XResponseType.SingleImage: + IR = cmfun.GetResponseMessageSingleImagesContent(requestMessage, ruleId, 0); + break; + default: + break; + } + return IR; + } + } + Core.WeixinResponseContent model = new Core.WeixinResponseContent() + { + OpenId = requestMessage.FromUserName, + RequestType = requestMessage.MsgType.ToString(), + RequestContent = requestMessage.Content, + ResponseType = Core.WeixinResponseContent.GetResponseType((int)requestMessage.MsgType), + ReponseContent = requestMessage.ToString(), + XmlContent = string.Empty + }; + model.Insert(); + + + return IR; + }); + + return requestHandler.GetResponseMessage() as IResponseMessageBase; + } + + + /// + /// 处理位置请求 + /// + /// + /// + public override async Task OnLocationRequestAsync(RequestMessageLocation requestMessage) + { + return await Task.Run(() => + { + var locationService = new LocationService(); + var responseMessage = locationService.GetResponseMessage(requestMessage as RequestMessageLocation); + return responseMessage; + }); + + } + + + public override async Task OnShortVideoRequestAsync(RequestMessageShortVideo requestMessage) + { + return await Task.Run(() => + { + var responseMessage = this.CreateResponseMessage(); + responseMessage.Content = "您刚才发送的是小视频"; + return responseMessage; + }); + + } + + /// + /// 处理图片请求 + /// + /// + /// + public override async Task OnImageRequestAsync(RequestMessageImage requestMessage) + { + //一隔一返回News或Image格式 + if (base.GlobalMessageContext.GetMessageContext(requestMessage).RequestMessages.Count() % 2 == 0) + { + var responseMessage = CreateResponseMessage(); + + responseMessage.Articles.Add(new Senparc.NeuChar.Entities.Article() + { + Title = "您刚才发送了图片信息", + Description = "您发送的图片将会显示在边上", + PicUrl = requestMessage.PicUrl, + Url = "https://sdk.weixin.senparc.com" + }); + responseMessage.Articles.Add(new Senparc.NeuChar.Entities.Article() + { + Title = "第二条", + Description = "第二条带连接的内容", + PicUrl = requestMessage.PicUrl, + Url = "https://sdk.weixin.senparc.com" + }); + return await Task.Run(() => + { + return responseMessage; + }); + //return responseMessage; + } + else + { + var responseMessage = CreateResponseMessage(); + responseMessage.Image.MediaId = requestMessage.MediaId; + return await Task.Run(() => + { + return responseMessage; + }); + //return responseMessage; + } + } + + /// + /// 处理语音请求 + /// + /// + /// + public override async Task OnVoiceRequestAsync(RequestMessageVoice requestMessage) + { + var responseMessage = CreateResponseMessage(); + //上传缩略图 + //var accessToken = Containers.AccessTokenContainer.TryGetAccessToken(appId, appSecret); + var uploadResult = Senparc.Weixin.MP.AdvancedAPIs.MediaApi.UploadTemporaryMedia(appId, UploadMediaFileType.image, + ServerUtility.ContentRootMapPath("~/Images/Logo.jpg")); + + //设置音乐信息 + responseMessage.Music.Title = "天籁之音"; + responseMessage.Music.Description = "播放您上传的语音"; + responseMessage.Music.MusicUrl = "https://sdk.weixin.senparc.com/Media/GetVoice?mediaId=" + requestMessage.MediaId; + responseMessage.Music.HQMusicUrl = "https://sdk.weixin.senparc.com/Media/GetVoice?mediaId=" + requestMessage.MediaId; + responseMessage.Music.ThumbMediaId = uploadResult.media_id; + + //推送一条客服消息 + try + { + CustomApi.SendText(appId, OpenId, "本次上传的音频MediaId:" + requestMessage.MediaId); + + } + catch + { + } + return await Task.Run(() => + { + return responseMessage; + }); + + } + /// + /// 处理视频请求 + /// + /// + /// + public override async Task OnVideoRequestAsync(RequestMessageVideo requestMessage) + { + var responseMessage = CreateResponseMessage(); + responseMessage.Content = "您发送了一条视频信息,ID:" + requestMessage.MediaId; + + #region 上传素材并推送到客户端 + + //Task.Factory.StartNew(async () => + //{ + // //上传素材 + // var dir = ServerUtility.ContentRootMapPath("~/App_Data/TempVideo/"); + // var file = await MediaApi.GetAsync(appId, requestMessage.MediaId, dir); + // var uploadResult = await MediaApi.UploadTemporaryMediaAsync(appId, UploadMediaFileType.video, file, 50000); + // await CustomApi.SendVideoAsync(appId, base.WeixinOpenId, uploadResult.media_id, "这是您刚才发送的视频", "这是一条视频消息"); + //}).ContinueWith(async task => + //{ + // if (task.Exception != null) + // { + // WeixinTrace.Log("OnVideoRequest()储存Video过程发生错误:", task.Exception.Message); + + + // var msg = string.Format("上传素材出错:{0}\r\n{1}", + // task.Exception.Message, + // task.Exception.InnerException != null + // ? task.Exception.InnerException.Message + // : null); + // await CustomApi.SendTextAsync(appId, base.WeixinOpenId, msg); + // } + //}); + + #endregion + return await Task.Run(() => + { + return responseMessage; + }); + } + + /// + /// 处理链接消息请求 + /// + /// + /// + public override async Task OnLinkRequestAsync(RequestMessageLink requestMessage) + { + var responseMessage = ResponseMessageBase.CreateFromRequestMessage(requestMessage); + responseMessage.Content = string.Format(@"您发送了一条连接信息: +Title:{0} +Description:{1} +Url:{2}", requestMessage.Title, requestMessage.Description, requestMessage.Url); + return await Task.Run(() => + { + return responseMessage; + }); + } + + public override async Task OnFileRequestAsync(RequestMessageFile requestMessage) + { + var responseMessage = requestMessage.CreateResponseMessage(); + responseMessage.Content = string.Format(@"您发送了一个文件: +文件名:{0} +说明:{1} +大小:{2} +MD5:{3}", requestMessage.Title, requestMessage.Description, requestMessage.FileTotalLen, requestMessage.FileMd5); + return await Task.Run(() => + { + return responseMessage; + }); + } + + /// + /// 处理事件请求(这个方法一般不用重写,这里仅作为示例出现。除非需要在判断具体Event类型以外对Event信息进行统一操作 + /// + /// + /// + public override async Task OnEventRequestAsync(IRequestMessageEventBase requestMessage) + { + var eventResponseMessage = await base.OnEventRequestAsync(requestMessage);//对于Event下属分类的重写方法,见:CustomerMessageHandler_Events.cs + //TODO: 对Event信息进行统一操作 + return eventResponseMessage; + } + + public override async Task OnUnknownTypeRequestAsync(RequestMessageUnknownType requestMessage) + { + /* + * 此方法用于应急处理SDK没有提供的消息类型, + * 原始XML可以通过requestMessage.RequestDocument(或this.RequestDocument)获取到。 + * 如果不重写此方法,遇到未知的请求类型将会抛出异常(v14.8.3 之前的版本就是这么做的) + */ + var msgType = Senparc.NeuChar.Helpers.MsgTypeHelper.GetRequestMsgTypeString(requestMessage.RequestDocument); + var responseMessage = this.CreateResponseMessage(); + responseMessage.Content = "未知消息类型:" + msgType; + XTrace.WriteLine("未知请求消息类型", requestMessage.RequestDocument.ToString()); + //WeixinTrace.SendCustomLog("未知请求消息类型", requestMessage.RequestDocument.ToString());//记录到日志中 + + return await Task.Run(() => + { + return responseMessage; + }); + } + + } +} diff --git a/COMCMS.API/Weixin/CustomMessageHandler/CustomMessageHandler_Events.cs b/COMCMS.API/Weixin/CustomMessageHandler/CustomMessageHandler_Events.cs new file mode 100644 index 0000000..5946493 --- /dev/null +++ b/COMCMS.API/Weixin/CustomMessageHandler/CustomMessageHandler_Events.cs @@ -0,0 +1,306 @@ +using COMCMS.API.Weixin.Download; +using NewLife.Configuration; +using Senparc.NeuChar.Entities; +using Senparc.Weixin.MP.Entities; +using System; +using System.Collections.Generic; +using System.Text; + +namespace COMCMS.API.Weixin.CustomMessageHandler +{ + public partial class CustomMessageHandler + { + public string GetDownloadInfo(CodeRecord codeRecord) + { + return string.Format(@"您已通过二维码验证,浏览器即将开始下载 Senparc.Weixin SDK 帮助文档。 +当前选择的版本:v{0}({1}) + +我们期待您的意见和建议,客服热线:400-031-8816。 + +感谢您对盛派网络的支持! + +© {2} Senparc", codeRecord.Version, codeRecord.IsWebVersion ? "网页版" : ".chm文档版", DateTime.Now.Year); + } + + public override IResponseMessageBase OnTextOrEventRequest(RequestMessageText requestMessage) + { + // 预处理文字或事件类型请求。 + // 这个请求是一个比较特殊的请求,通常用于统一处理来自文字或菜单按钮的同一个执行逻辑, + // 会在执行OnTextRequest或OnEventRequest之前触发,具有以下一些特征: + // 1、如果返回null,则继续执行OnTextRequest或OnEventRequest + // 2、如果返回不为null,则终止执行OnTextRequest或OnEventRequest,返回最终ResponseMessage + // 3、如果是事件,则会将RequestMessageEvent自动转为RequestMessageText类型,其中RequestMessageText.Content就是RequestMessageEvent.EventKey + + if (requestMessage.Content == "OneClick") + { + var strongResponseMessage = CreateResponseMessage(); + strongResponseMessage.Content = "您点击了底部按钮。\r\n为了测试微信软件换行bug的应对措施,这里做了一个——\r\n换行"; + return strongResponseMessage; + } + return null;//返回null,则继续执行OnTextRequest或OnEventRequest + } + + + public string GetWXApiUrl(string url, string token, string openid) + { + if (url.Contains("?")) + { + return url + "&token=" + token + "&openid=" + openid; + } + return url + "?token=" + token + "&openid=" + openid; + } + + + /// + /// 点击事件 + /// + /// + /// + public override IResponseMessageBase OnEvent_ClickRequest(RequestMessageEvent_Click requestMessage) + { + //菜单点击,需要跟创建菜单时的Key匹配 + IResponseMessageBase IR = null; + Common.MessageFunction cmfun = new Common.MessageFunction(); + int responseType = 0, ruleId = 0; + + string keywords = requestMessage.EventKey; //事件key + + //先精确匹配,再模糊匹配 + Core.WeixinRequestRule rule = Core.WeixinRequestRule.Find(Core.WeixinRequestRule._.Keywords == keywords & Core.WeixinRequestRule._.RequestType == (int)Core.WeixinRequestRule.XRequestType.CustomMenu); + + if (rule == null) + { + //找不到规则 + Core.WeixinResponseContent entity = new Core.WeixinResponseContent() + { + OpenId = requestMessage.FromUserName, + RequestType = requestMessage.MsgType.ToString(), + RequestContent = requestMessage.EventKey, + ResponseType = "none", + ReponseContent = "未取到相应的事件规则", + XmlContent = requestMessage.ToUserName + }; + entity.Insert(); + return cmfun.GetResponseMessageTxtByContent(requestMessage, "未取到相应的事件规则", 0); + } + responseType = rule.ResponseType; + ruleId = rule.Id; + switch (responseType) + { + case (int)Core.WeixinRequestRule.XResponseType.Text: + //发送纯文字 + IR = cmfun.GetResponseMessageTxt(requestMessage, ruleId, 0); + break; + case (int)Core.WeixinRequestRule.XResponseType.Image: + //发送多图文 + IR = cmfun.GetResponseMessageNews(requestMessage, ruleId, 0); + break; + case (int)Core.WeixinRequestRule.XResponseType.Voice: + //发送语音 + IR = cmfun.GetResponseMessageeMusic(requestMessage, ruleId, 0); + break; + case (int)Core.WeixinRequestRule.XResponseType.SingleImage: + IR = cmfun.GetResponseMessageSingleImagesContent(requestMessage, ruleId, 0); + break; + default: + break; + } + Core.WeixinResponseContent model = new Core.WeixinResponseContent() + { + OpenId = requestMessage.FromUserName, + RequestType = requestMessage.MsgType.ToString(), + RequestContent = requestMessage.EventKey, + ResponseType = Core.WeixinResponseContent.GetResponseType((int)requestMessage.MsgType), + ReponseContent = requestMessage.ToString(), + XmlContent = string.Empty + }; + model.Insert(); + + return IR; + } + + /// + /// 进入事件 + /// + /// + /// + public override IResponseMessageBase OnEvent_EnterRequest(RequestMessageEvent_Enter requestMessage) + { + var responseMessage = ResponseMessageBase.CreateFromRequestMessage(requestMessage); + responseMessage.Content = "您刚才发送了ENTER事件请求。"; + return responseMessage; + } + + /// + /// 位置事件 + /// + /// + /// + public override IResponseMessageBase OnEvent_LocationRequest(RequestMessageEvent_Location requestMessage) + { + //这里是微信客户端(通过微信服务器)自动发送过来的位置信息 + var responseMessage = CreateResponseMessage(); + responseMessage.Content = "这里写什么都无所谓,比如:上帝爱你!"; + return responseMessage;//这里也可以返回null(需要注意写日志时候null的问题) + } + + /// + /// 通过二维码扫描关注扫描事件 + /// + /// + /// + public override IResponseMessageBase OnEvent_ScanRequest(RequestMessageEvent_Scan requestMessage) + { + //通过扫描关注 + var responseMessage = CreateResponseMessage(); + + //下载文档 + if (!string.IsNullOrEmpty(requestMessage.EventKey)) + { + //这里可以写扫码逻辑 + } + + responseMessage.Content = responseMessage.Content ?? string.Format("通过扫描二维码进入,场景值:{0}", requestMessage.EventKey); + + return responseMessage; + } + + /// + /// 打开网页事件 + /// + /// + /// + public override IResponseMessageBase OnEvent_ViewRequest(RequestMessageEvent_View requestMessage) + { + //说明:这条消息只作为接收,下面的responseMessage到达不了客户端,类似OnEvent_UnsubscribeRequest + var responseMessage = CreateResponseMessage(); + responseMessage.Content = "您点击了view按钮,将打开网页:" + requestMessage.EventKey; + return responseMessage; + } + + /// + /// 群发完成事件 + /// + /// + /// + public override IResponseMessageBase OnEvent_MassSendJobFinishRequest(RequestMessageEvent_MassSendJobFinish requestMessage) + { + var responseMessage = CreateResponseMessage(); + responseMessage.Content = "接收到了群发完成的信息。"; + return responseMessage; + } + + /// + /// 订阅(关注)事件 + /// + /// + public override IResponseMessageBase OnEvent_SubscribeRequest(RequestMessageEvent_Subscribe requestMessage) + { + return new Common.MessageFunction().EventSubscribe(6, requestMessage); + } + + + /// + /// 退订 + /// 实际上用户无法收到非订阅账号的消息,所以这里可以随便写。 + /// unsubscribe事件的意义在于及时删除网站应用中已经记录的OpenID绑定,消除冗余数据。并且关注用户流失的情况。 + /// + /// + public override IResponseMessageBase OnEvent_UnsubscribeRequest(RequestMessageEvent_Unsubscribe requestMessage) + { + var responseMessage = base.CreateResponseMessage(); + responseMessage.Content = "有空再来"; + return responseMessage; + } + + /// + /// 事件之扫码推事件(scancode_push) + /// + /// + /// + public override IResponseMessageBase OnEvent_ScancodePushRequest(RequestMessageEvent_Scancode_Push requestMessage) + { + var responseMessage = base.CreateResponseMessage(); + responseMessage.Content = "事件之扫码推事件"; + return responseMessage; + } + + /// + /// 事件之扫码推事件且弹出“消息接收中”提示框(scancode_waitmsg) + /// + /// + /// + public override IResponseMessageBase OnEvent_ScancodeWaitmsgRequest(RequestMessageEvent_Scancode_Waitmsg requestMessage) + { + var responseMessage = base.CreateResponseMessage(); + responseMessage.Content = "事件之扫码推事件且弹出“消息接收中”提示框"; + return responseMessage; + } + + + /// + /// 事件之弹出拍照或者相册发图(pic_photo_or_album) + /// + /// + /// + public override IResponseMessageBase OnEvent_PicPhotoOrAlbumRequest(RequestMessageEvent_Pic_Photo_Or_Album requestMessage) + { + var responseMessage = base.CreateResponseMessage(); + responseMessage.Content = "事件之弹出拍照或者相册发图"; + return responseMessage; + } + + /// + /// 事件之弹出系统拍照发图(pic_sysphoto) + /// 实际测试时发现微信并没有推送RequestMessageEvent_Pic_Sysphoto消息,只能接收到用户在微信中发送的图片消息。 + /// + /// + /// + public override IResponseMessageBase OnEvent_PicSysphotoRequest(RequestMessageEvent_Pic_Sysphoto requestMessage) + { + var responseMessage = base.CreateResponseMessage(); + responseMessage.Content = "事件之弹出系统拍照发图"; + return responseMessage; + } + + /// + /// 事件之弹出微信相册发图器(pic_weixin) + /// + /// + /// + public override IResponseMessageBase OnEvent_PicWeixinRequest(RequestMessageEvent_Pic_Weixin requestMessage) + { + var responseMessage = base.CreateResponseMessage(); + responseMessage.Content = "事件之弹出微信相册发图器"; + return responseMessage; + } + + /// + /// 事件之弹出地理位置选择器(location_select) + /// + /// + /// + public override IResponseMessageBase OnEvent_LocationSelectRequest(RequestMessageEvent_Location_Select requestMessage) + { + var responseMessage = base.CreateResponseMessage(); + responseMessage.Content = "事件之弹出地理位置选择器"; + return responseMessage; + } + + #region 微信认证事件推送 + + public override IResponseMessageBase OnEvent_QualificationVerifySuccessRequest(RequestMessageEvent_QualificationVerifySuccess requestMessage) + { + //以下方法可以强制定义返回的字符串值 + //TextResponseMessage = "your content"; + //return null; + + return new SuccessResponseMessage();//返回"success"字符串 + } + + #endregion + + } + + +} diff --git a/COMCMS.API/Weixin/Download/CodeRecord.cs b/COMCMS.API/Weixin/Download/CodeRecord.cs new file mode 100644 index 0000000..63d7432 --- /dev/null +++ b/COMCMS.API/Weixin/Download/CodeRecord.cs @@ -0,0 +1,18 @@ +using Senparc.Weixin.MP.AdvancedAPIs.QrCode; +using System; +using System.Collections.Generic; +using System.Text; + +namespace COMCMS.API.Weixin.Download +{ + public class CodeRecord + { + public string Key { get; set; } + public int QrCodeId { get; set; } + public CreateQrCodeResult QrCodeTicket { get; set; } + public string Version { get; set; } + public bool Used { get; set; } + public bool AllowDownload { get; set; } + public bool IsWebVersion { get; set; } + } +} diff --git a/COMCMS.API/Weixin/LocationService.cs b/COMCMS.API/Weixin/LocationService.cs new file mode 100644 index 0000000..09d6c71 --- /dev/null +++ b/COMCMS.API/Weixin/LocationService.cs @@ -0,0 +1,85 @@ +using Senparc.CO2NET.Helpers; +using Senparc.CO2NET.Helpers.BaiduMap; +using Senparc.CO2NET.Helpers.GoogleMap; +using Senparc.NeuChar.Entities; +using Senparc.Weixin.MP.Entities; +using System; +using System.Collections.Generic; +using System.Text; + +namespace COMCMS.API.Weixin +{ + public class LocationService + { + public ResponseMessageNews GetResponseMessage(RequestMessageLocation requestMessage) + { + var responseMessage = ResponseMessageBase.CreateFromRequestMessage(requestMessage); + + #region 百度地图 + + { + var markersList = new List(); + markersList.Add(new BaiduMarkers() + { + Longitude = requestMessage.Location_X, + Latitude = requestMessage.Location_Y, + Color = "red", + Label = "S", + Size = BaiduMarkerSize.m + }); + + var mapUrl = BaiduMapHelper.GetBaiduStaticMap(requestMessage.Location_X, requestMessage.Location_Y, 1, 6, markersList); + responseMessage.Articles.Add(new Article() + { + Description = string.Format("【来自百度地图】您刚才发送了地理位置信息。Location_X:{0},Location_Y:{1},Scale:{2},标签:{3}", + requestMessage.Location_X, requestMessage.Location_Y, + requestMessage.Scale, requestMessage.Label), + PicUrl = mapUrl, + Title = "定位地点周边地图", + Url = mapUrl + }); + } + + #endregion + + #region GoogleMap + + { + var markersList = new List(); + markersList.Add(new GoogleMapMarkers() + { + X = requestMessage.Location_X, + Y = requestMessage.Location_Y, + Color = "red", + Label = "S", + Size = GoogleMapMarkerSize.Default, + }); + var mapSize = "480x600"; + var mapUrl = GoogleMapHelper.GetGoogleStaticMap(19 /*requestMessage.Scale*//*微信和GoogleMap的Scale不一致,这里建议使用固定值*/, + markersList, mapSize); + responseMessage.Articles.Add(new Article() + { + Description = string.Format("【来自GoogleMap】您刚才发送了地理位置信息。Location_X:{0},Location_Y:{1},Scale:{2},标签:{3}", + requestMessage.Location_X, requestMessage.Location_Y, + requestMessage.Scale, requestMessage.Label), + PicUrl = mapUrl, + Title = "定位地点周边地图", + Url = mapUrl + }); + } + + #endregion + + + responseMessage.Articles.Add(new Article() + { + Title = "微信公众平台SDK 官网链接", + Description = "Senparc.Weixin.MK SDK地址", + PicUrl = "https://sdk.weixin.senparc.com/images/logo.jpg", + Url = "https://sdk.weixin.senparc.com" + }); + + return responseMessage; + } + } +} diff --git a/COMCMS.Common/COMCMS.Common.csproj b/COMCMS.Common/COMCMS.Common.csproj index 4633556..148e029 100644 --- a/COMCMS.Common/COMCMS.Common.csproj +++ b/COMCMS.Common/COMCMS.Common.csproj @@ -1,20 +1,20 @@ - + - netcoreapp2.1 + netcoreapp3.1 - - - + + + + + - - C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.authentication.cookies\2.1.1\lib\netstandard2.0\Microsoft.AspNetCore.Authentication.Cookies.dll - + diff --git a/COMCMS.Common/PinYinHelper.cs b/COMCMS.Common/PinYinHelper.cs new file mode 100644 index 0000000..97200d3 --- /dev/null +++ b/COMCMS.Common/PinYinHelper.cs @@ -0,0 +1,68 @@ +using Microsoft.International.Converters.PinYinConverter; +using System; +using System.Collections.Generic; +using System.Text; + +namespace COMCMS.Common +{ + public class PinYinHelper + { + /// + /// 默认编码 + /// + //private static Encoding gb2312 = Encoding.GetEncoding("GB2312"); + + #region 汉字转化为拼音 + /// + /// 汉字转化为拼音 + /// + /// 汉字 + /// 全拼 + public static string GetPinyin(string str) + { + string r = string.Empty; + foreach (char obj in str) + { + try + { + ChineseChar chineseChar = new ChineseChar(obj); + string t = chineseChar.Pinyins[0].ToString(); + r += t.Substring(0, t.Length - 1); + } + catch + { + r += obj.ToString(); + } + } + return r; + } + #endregion + + #region 汉字转化为拼音首字母 + /// + /// 汉字转化为拼音首字母 + /// + /// 汉字 + /// 首字母 + public static string GetFirstPinyin(string str) + { + string r = string.Empty; + foreach (char obj in str) + { + try + { + ChineseChar chineseChar = new ChineseChar(obj); + string t = chineseChar.Pinyins[0].ToString(); + r += t.Substring(0, 1); + } + catch + { + r += obj.ToString(); + } + } + return r; + } + #endregion + + } +} diff --git a/COMCMS.Common/ThumbnailHelper.cs b/COMCMS.Common/ThumbnailHelper.cs index 0137a40..386dd00 100644 --- a/COMCMS.Common/ThumbnailHelper.cs +++ b/COMCMS.Common/ThumbnailHelper.cs @@ -22,11 +22,11 @@ namespace COMCMS.Common /// /// 程序绝对目录 /// - private static string _ContentRootPath = DI.ServiceProvider.GetService().ContentRootPath; + private static string _ContentRootPath = DI.ServiceProvider.GetService().ContentRootPath; /// /// 静态文件 /// - private static string _WebRootPath = DI.ServiceProvider.GetService().WebRootPath; + private static string _WebRootPath = DI.ServiceProvider.GetService().WebRootPath; #region 方式 public enum CutMode diff --git a/COMCMS.Common/Utils.cs b/COMCMS.Common/Utils.cs index 75fb6ac..01eb5ee 100644 --- a/COMCMS.Common/Utils.cs +++ b/COMCMS.Common/Utils.cs @@ -9,6 +9,9 @@ using System.Net; using System.IO; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration.Json; +using System.Net.NetworkInformation; +using System.Linq; +using System.Net.Sockets; namespace COMCMS.Common { @@ -75,6 +78,32 @@ namespace COMCMS.Common /// 配送状态 "未配送", "配货中", "已配送", "已收到", "退货中", "已退货" /// public static string[] DeliverState = { "未配送", "配货中", "已配送", "已收到", "退货中", "已退货" }; + /// + /// cms类型 + /// + public enum CMSType + { + /// + /// 文章分类 + /// + ArticleCategory=0, + /// + /// 文章 + /// + Article=1, + /// + /// 商品分类 + /// + ProductCategory=2, + /// + /// 商品详情 + /// + Product=3, + /// + /// 首页 + /// + Home=99 + } #endregion #region 验证部分 @@ -99,6 +128,17 @@ namespace COMCMS.Common return Regex.IsMatch(str, @"^[A-Za-z0-9]+$"); } + /// + /// 判断是否为正确的 + /// + /// + /// + public static bool IsFilePath(string str) + { + //A-Z, a-z, 0-9, -, /, = + return Regex.IsMatch(str, @"[A-Za-z0-9-\/]"); + } + /// /// 验证对象是否为货币格式 /// @@ -177,7 +217,7 @@ namespace COMCMS.Common { if (str.Length != 11) return false; - return Regex.IsMatch(str, @"^1[3|4|5|7|8][0-9]\d{4,8}$"); + return Regex.IsMatch(str, @"^1[3|4|5|7|8|9][0-9]\d{4,8}$"); } /// /// 是否为ip @@ -308,6 +348,19 @@ namespace COMCMS.Common #endregion #region 获取部分 + + /// + /// 获取配置 + /// + /// 路径,如:SystemSetting:COMCMSPrefixKey + /// + public static string GetSetting(string path) + { + string value = Configuration[path]; + + return value; + } + /// /// 返回字符串真实长度, 1个汉字长度为2 /// @@ -674,6 +727,12 @@ namespace COMCMS.Common public static string GetIP() { string userHostAddress = MyHttpContext.Current.Request.HttpContext.Connection.RemoteIpAddress.ToString(); + //2019-05-11 增加反向代理获取真实IP + string xForwardedForAddress = MyHttpContext.Current.Request.Headers["X-Forwarded-For"]; + if (!string.IsNullOrEmpty(userHostAddress) && !string.IsNullOrEmpty(xForwardedForAddress) && userHostAddress != xForwardedForAddress) + { + return xForwardedForAddress; + } if (!string.IsNullOrEmpty(userHostAddress) && Utils.IsIP(userHostAddress)) { if (userHostAddress == "::1") @@ -994,6 +1053,37 @@ namespace COMCMS.Common return ""; } } + + /// + /// 将对象转换为Int32类型 + /// + /// 要转换的字符串 + /// 缺省值 + /// 转换后的int类型结果 + public static int StrToInt(string str, int defValue) + { + if (string.IsNullOrEmpty(str) || str.Trim().Length >= 11 || !Regex.IsMatch(str.Trim(), @"^([-]|[0-9])[0-9]*(\.\w*)?$")) + return defValue; + + int rv; + if (Int32.TryParse(str, out rv)) + return rv; + + return Convert.ToInt32(StrToFloat(str, defValue)); + } + /// + /// string型转换为float型 + /// + /// 要转换的字符串 + /// 缺省值 + /// 转换后的int类型结果 + public static float StrToFloat(object strValue, float defValue) + { + if ((strValue == null)) + return defValue; + + return StrToFloat(strValue.ToString(), defValue); + } #endregion #region COMCMS类型 @@ -1011,6 +1101,24 @@ namespace COMCMS.Common } #endregion + private static String[] _Excludes = new[] { "Loopback", "VMware", "VBox", "Virtual", "Teredo", "Microsoft", "VPN", "VNIC", "IEEE" }; + /// 获取所有网卡MAC地址 + /// + public static IEnumerable GetMacs() + { + foreach (var item in NetworkInterface.GetAllNetworkInterfaces()) + { + if (_Excludes.Any(e => item.Description.Contains(e))) continue; + if (item.Speed < 1_000_000) continue; + + var addrs = item.GetIPProperties().UnicastAddresses.Where(e => e.Address.AddressFamily == AddressFamily.InterNetwork).ToArray(); + if (addrs.All(e => IPAddress.IsLoopback(e.Address))) continue; + + var mac = item.GetPhysicalAddress()?.GetAddressBytes(); + if (mac != null && mac.Length == 6) yield return mac; + } + } + } #region 常用扩展方法 diff --git a/COMCMS.Core/Article/文章.Biz.cs b/COMCMS.Core/Article/文章.Biz.cs index 0b3e65a..ab9ff46 100644 --- a/COMCMS.Core/Article/文章.Biz.cs +++ b/COMCMS.Core/Article/文章.Biz.cs @@ -153,6 +153,65 @@ namespace COMCMS.Core #endregion #region 业务操作 + /// + /// 获取上一条记录/前一条记录 + /// + /// ID + /// + public static Article GetPrev(int id) + { + Article entity = Article.FindById(id); + if (entity != null) + { + //获取上一条记录 + IList
list = Article.FindAll(_.Id > entity.Id & _.KId == entity.KId & _.Sequence <= entity.Sequence, string.Format("{0} Desc,{1} Asc", _.Sequence, _.Id), null, 0, 1); + if (list != null && list.Count > 0) + return list[0]; + else + { + list = Article.FindAll(_.Id != entity.Id & _.KId == entity.KId & _.Sequence < entity.Sequence, string.Format("{0} Desc,{1} Asc", _.Sequence, _.Id), null, 0, 1); + if (list != null && list.Count > 0) + { + return list[0]; + } + else + return null; + } + + } + else + return null; + } + + /// + /// 获取下一条记录/后一条记录 + /// + /// + /// + public static Article GetNext(int id) + { + Article entity = Article.FindById(id); + if (entity != null) + { + //获取上一条记录 + IList
list = Article.FindAll(_.Id != entity.Id & _.KId == entity.KId & _.Sequence > entity.Sequence, string.Format("{0} Asc,{1} Desc", _.Sequence, _.Id), null, 0, 1); + if (list != null && list.Count > 0) + return list[0]; + else + { + list = Article.FindAll(_.Id < entity.Id & _.KId == entity.KId & _.Sequence >= entity.Sequence, string.Format("{0} Asc,{1} Desc", _.Sequence, _.Id), null, 0, 1); + if (list != null && list.Count > 0) + { + return list[0]; + } + else + return null; + } + + } + else + return null; + } #endregion } } \ No newline at end of file diff --git a/COMCMS.Core/Article/文章栏目.Biz.cs b/COMCMS.Core/Article/文章栏目.Biz.cs index e82eafa..071515e 100644 --- a/COMCMS.Core/Article/文章栏目.Biz.cs +++ b/COMCMS.Core/Article/文章栏目.Biz.cs @@ -142,6 +142,23 @@ namespace COMCMS.Core return Find(_.Id == id); } + + /// 根据目录查找 + /// 目录 + /// 实体对象 + public static ArticleCategory FindByFilePath(string path) + { + if (string.IsNullOrEmpty(path)) return null; + + // 实体缓存 + if (Meta.Count < 1000) return Meta.Cache.Find(e => e.FilePath == path); + + // 单对象缓存 + //return Meta.SingleCache[id]; + + return Find(_.FilePath == path); + } + /// /// 根据父ID查询所有子项 /// @@ -325,6 +342,35 @@ namespace COMCMS.Core } } } + + /// + /// 获取当前位置 + /// + /// 类别ID + /// + public static string GetNav(int kid) + { + string tpl = "{1}"; + string re = string.Empty; + ArticleCategory model = Find(_.Id == kid); + if (model == null) + { + re = string.Format(tpl, "/", "首页") + re;//查到最后肯定是没有 + } + else + { + re += " > " + string.Format(tpl, "/article/index/" + model.Id, model.KindName); + if (model.PId != 0) + { + re = GetNav(model.PId) + re; + } + else + { + re = string.Format(tpl, "/", "首页") + re;//查到最后肯定是没有 + } + } + return re; + } #endregion } } \ No newline at end of file diff --git a/COMCMS.Core/Article/文章栏目.cs b/COMCMS.Core/Article/文章栏目.cs index dd775a1..7b8c039 100644 --- a/COMCMS.Core/Article/文章栏目.cs +++ b/COMCMS.Core/Article/文章栏目.cs @@ -20,7 +20,7 @@ namespace COMCMS.Core [DisplayName("编号")] [Description("编号")] [DataObjectField(true, true, false, 0)] - [BindColumn("Id", "编号", "int")] + [BindColumn("Id", "编号", "")] public Int32 Id { get { return _Id; } set { if (OnPropertyChanging(__.Id, value)) { _Id = value; OnPropertyChanged(__.Id); } } } private String _KindName; @@ -28,7 +28,7 @@ namespace COMCMS.Core [DisplayName("栏目名称")] [Description("栏目名称")] [DataObjectField(false, false, true, 250)] - [BindColumn("KindName", "栏目名称", "nvarchar(250)")] + [BindColumn("KindName", "栏目名称", "")] public String KindName { get { return _KindName; } set { if (OnPropertyChanging(__.KindName, value)) { _KindName = value; OnPropertyChanged(__.KindName); } } } private String _SubTitle; @@ -36,7 +36,7 @@ namespace COMCMS.Core [DisplayName("栏目副标题")] [Description("栏目副标题")] [DataObjectField(false, false, true, 250)] - [BindColumn("SubTitle", "栏目副标题", "nvarchar(250)")] + [BindColumn("SubTitle", "栏目副标题", "")] public String SubTitle { get { return _SubTitle; } set { if (OnPropertyChanging(__.SubTitle, value)) { _SubTitle = value; OnPropertyChanged(__.SubTitle); } } } private String _KindTitle; @@ -44,7 +44,7 @@ namespace COMCMS.Core [DisplayName("栏目标题")] [Description("栏目标题,填写则在浏览器替换此标题")] [DataObjectField(false, false, true, 250)] - [BindColumn("KindTitle", "栏目标题,填写则在浏览器替换此标题", "nvarchar(250)")] + [BindColumn("KindTitle", "栏目标题,填写则在浏览器替换此标题", "")] public String KindTitle { get { return _KindTitle; } set { if (OnPropertyChanging(__.KindTitle, value)) { _KindTitle = value; OnPropertyChanged(__.KindTitle); } } } private String _Keyword; @@ -52,7 +52,7 @@ namespace COMCMS.Core [DisplayName("描述")] [Description("描述")] [DataObjectField(false, false, true, 250)] - [BindColumn("Keyword", "描述", "nvarchar(250)")] + [BindColumn("Keyword", "描述", "")] public String Keyword { get { return _Keyword; } set { if (OnPropertyChanging(__.Keyword, value)) { _Keyword = value; OnPropertyChanged(__.Keyword); } } } private String _Description; @@ -60,7 +60,7 @@ namespace COMCMS.Core [DisplayName("介绍")] [Description("介绍")] [DataObjectField(false, false, true, 250)] - [BindColumn("Description", "介绍", "nvarchar(250)")] + [BindColumn("Description", "介绍", "")] public String Description { get { return _Description; } set { if (OnPropertyChanging(__.Description, value)) { _Description = value; OnPropertyChanged(__.Description); } } } private String _LinkURL; @@ -68,7 +68,7 @@ namespace COMCMS.Core [DisplayName("跳转链接")] [Description("跳转链接")] [DataObjectField(false, false, true, 250)] - [BindColumn("LinkURL", "跳转链接", "nvarchar(250)")] + [BindColumn("LinkURL", "跳转链接", "")] public String LinkURL { get { return _LinkURL; } set { if (OnPropertyChanging(__.LinkURL, value)) { _LinkURL = value; OnPropertyChanged(__.LinkURL); } } } private String _TitleColor; @@ -76,7 +76,7 @@ namespace COMCMS.Core [DisplayName("类别名称颜色")] [Description("类别名称颜色")] [DataObjectField(false, false, true, 50)] - [BindColumn("TitleColor", "类别名称颜色", "nvarchar(50)")] + [BindColumn("TitleColor", "类别名称颜色", "")] public String TitleColor { get { return _TitleColor; } set { if (OnPropertyChanging(__.TitleColor, value)) { _TitleColor = value; OnPropertyChanged(__.TitleColor); } } } private String _TemplateFile; @@ -84,7 +84,7 @@ namespace COMCMS.Core [DisplayName("模板")] [Description("模板")] [DataObjectField(false, false, true, 250)] - [BindColumn("TemplateFile", "模板", "nvarchar(250)")] + [BindColumn("TemplateFile", "模板", "")] public String TemplateFile { get { return _TemplateFile; } set { if (OnPropertyChanging(__.TemplateFile, value)) { _TemplateFile = value; OnPropertyChanged(__.TemplateFile); } } } private String _DetailTemplateFile; @@ -92,7 +92,7 @@ namespace COMCMS.Core [DisplayName("详情模板")] [Description("详情模板")] [DataObjectField(false, false, true, 250)] - [BindColumn("DetailTemplateFile", "详情模板", "nvarchar(250)")] + [BindColumn("DetailTemplateFile", "详情模板", "")] public String DetailTemplateFile { get { return _DetailTemplateFile; } set { if (OnPropertyChanging(__.DetailTemplateFile, value)) { _DetailTemplateFile = value; OnPropertyChanged(__.DetailTemplateFile); } } } private String _KindDomain; @@ -100,7 +100,7 @@ namespace COMCMS.Core [DisplayName("类别域名")] [Description("类别域名(保留)")] [DataObjectField(false, false, true, 250)] - [BindColumn("KindDomain", "类别域名(保留)", "nvarchar(250)")] + [BindColumn("KindDomain", "类别域名(保留)", "")] public String KindDomain { get { return _KindDomain; } set { if (OnPropertyChanging(__.KindDomain, value)) { _KindDomain = value; OnPropertyChanged(__.KindDomain); } } } private Int32 _IsList; @@ -108,7 +108,7 @@ namespace COMCMS.Core [DisplayName("是否为列表页面")] [Description("是否为列表页面")] [DataObjectField(false, false, false, 0)] - [BindColumn("IsList", "是否为列表页面", "int")] + [BindColumn("IsList", "是否为列表页面", "")] public Int32 IsList { get { return _IsList; } set { if (OnPropertyChanging(__.IsList, value)) { _IsList = value; OnPropertyChanged(__.IsList); } } } private Int32 _PageSize; @@ -116,7 +116,7 @@ namespace COMCMS.Core [DisplayName("每页显示数量")] [Description("每页显示数量")] [DataObjectField(false, false, false, 0)] - [BindColumn("PageSize", "每页显示数量", "int")] + [BindColumn("PageSize", "每页显示数量", "")] public Int32 PageSize { get { return _PageSize; } set { if (OnPropertyChanging(__.PageSize, value)) { _PageSize = value; OnPropertyChanged(__.PageSize); } } } private Int32 _PId; @@ -124,7 +124,7 @@ namespace COMCMS.Core [DisplayName("上级ID")] [Description("上级ID")] [DataObjectField(false, false, false, 0)] - [BindColumn("PId", "上级ID", "int")] + [BindColumn("PId", "上级ID", "")] public Int32 PId { get { return _PId; } set { if (OnPropertyChanging(__.PId, value)) { _PId = value; OnPropertyChanged(__.PId); } } } private Int32 _Level; @@ -132,7 +132,7 @@ namespace COMCMS.Core [DisplayName("级别")] [Description("级别")] [DataObjectField(false, false, false, 0)] - [BindColumn("Level", "级别", "int")] + [BindColumn("Level", "级别", "")] public Int32 Level { get { return _Level; } set { if (OnPropertyChanging(__.Level, value)) { _Level = value; OnPropertyChanged(__.Level); } } } private String _Location; @@ -140,7 +140,7 @@ namespace COMCMS.Core [DisplayName("路径")] [Description("路径")] [DataObjectField(false, false, true, 100)] - [BindColumn("Location", "路径", "nvarchar(100)")] + [BindColumn("Location", "路径", "")] public String Location { get { return _Location; } set { if (OnPropertyChanging(__.Location, value)) { _Location = value; OnPropertyChanged(__.Location); } } } private Int32 _IsHide; @@ -148,7 +148,7 @@ namespace COMCMS.Core [DisplayName("是否隐藏")] [Description("是否隐藏")] [DataObjectField(false, false, false, 0)] - [BindColumn("IsHide", "是否隐藏", "int")] + [BindColumn("IsHide", "是否隐藏", "")] public Int32 IsHide { get { return _IsHide; } set { if (OnPropertyChanging(__.IsHide, value)) { _IsHide = value; OnPropertyChanged(__.IsHide); } } } private Int32 _IsLock; @@ -156,7 +156,7 @@ namespace COMCMS.Core [DisplayName("是否锁定")] [Description("是否锁定,不允许删除")] [DataObjectField(false, false, false, 0)] - [BindColumn("IsLock", "是否锁定,不允许删除", "int")] + [BindColumn("IsLock", "是否锁定,不允许删除", "")] public Int32 IsLock { get { return _IsLock; } set { if (OnPropertyChanging(__.IsLock, value)) { _IsLock = value; OnPropertyChanged(__.IsLock); } } } private Int32 _IsDel; @@ -164,7 +164,7 @@ namespace COMCMS.Core [DisplayName("是否删除")] [Description("是否删除,已经删除到回收站")] [DataObjectField(false, false, false, 0)] - [BindColumn("IsDel", "是否删除,已经删除到回收站", "int")] + [BindColumn("IsDel", "是否删除,已经删除到回收站", "")] public Int32 IsDel { get { return _IsDel; } set { if (OnPropertyChanging(__.IsDel, value)) { _IsDel = value; OnPropertyChanged(__.IsDel); } } } private Int32 _IsComment; @@ -172,7 +172,7 @@ namespace COMCMS.Core [DisplayName("是否允许评论")] [Description("是否允许评论")] [DataObjectField(false, false, false, 0)] - [BindColumn("IsComment", "是否允许评论", "int")] + [BindColumn("IsComment", "是否允许评论", "")] public Int32 IsComment { get { return _IsComment; } set { if (OnPropertyChanging(__.IsComment, value)) { _IsComment = value; OnPropertyChanged(__.IsComment); } } } private Int32 _IsMember; @@ -180,7 +180,7 @@ namespace COMCMS.Core [DisplayName("是否会员栏目")] [Description("是否会员栏目")] [DataObjectField(false, false, false, 0)] - [BindColumn("IsMember", "是否会员栏目", "int")] + [BindColumn("IsMember", "是否会员栏目", "")] public Int32 IsMember { get { return _IsMember; } set { if (OnPropertyChanging(__.IsMember, value)) { _IsMember = value; OnPropertyChanged(__.IsMember); } } } private Int32 _IsShowSubDetail; @@ -188,7 +188,7 @@ namespace COMCMS.Core [DisplayName("是否显示下级栏目内容")] [Description("是否显示下级栏目内容")] [DataObjectField(false, false, false, 0)] - [BindColumn("IsShowSubDetail", "是否显示下级栏目内容", "int")] + [BindColumn("IsShowSubDetail", "是否显示下级栏目内容", "")] public Int32 IsShowSubDetail { get { return _IsShowSubDetail; } set { if (OnPropertyChanging(__.IsShowSubDetail, value)) { _IsShowSubDetail = value; OnPropertyChanged(__.IsShowSubDetail); } } } private Int32 _CatalogId; @@ -196,7 +196,7 @@ namespace COMCMS.Core [DisplayName("模型ID")] [Description("模型ID")] [DataObjectField(false, false, false, 0)] - [BindColumn("CatalogId", "模型ID", "int")] + [BindColumn("CatalogId", "模型ID", "")] public Int32 CatalogId { get { return _CatalogId; } set { if (OnPropertyChanging(__.CatalogId, value)) { _CatalogId = value; OnPropertyChanged(__.CatalogId); } } } private Int32 _Counts; @@ -204,7 +204,7 @@ namespace COMCMS.Core [DisplayName("详情数量")] [Description("详情数量,缓存")] [DataObjectField(false, false, false, 0)] - [BindColumn("Counts", "详情数量,缓存", "int")] + [BindColumn("Counts", "详情数量,缓存", "")] public Int32 Counts { get { return _Counts; } set { if (OnPropertyChanging(__.Counts, value)) { _Counts = value; OnPropertyChanged(__.Counts); } } } private Int32 _Rank; @@ -212,7 +212,7 @@ namespace COMCMS.Core [DisplayName("排序")] [Description("排序")] [DataObjectField(false, false, false, 0)] - [BindColumn("Rank", "排序", "int")] + [BindColumn("Rank", "排序", "")] public Int32 Rank { get { return _Rank; } set { if (OnPropertyChanging(__.Rank, value)) { _Rank = value; OnPropertyChanged(__.Rank); } } } private String _Icon; @@ -220,7 +220,7 @@ namespace COMCMS.Core [DisplayName("图标")] [Description("图标")] [DataObjectField(false, false, true, 100)] - [BindColumn("Icon", "图标", "nvarchar(100)")] + [BindColumn("Icon", "图标", "")] public String Icon { get { return _Icon; } set { if (OnPropertyChanging(__.Icon, value)) { _Icon = value; OnPropertyChanged(__.Icon); } } } private String _ClassName; @@ -228,7 +228,7 @@ namespace COMCMS.Core [DisplayName("样式名称")] [Description("样式名称")] [DataObjectField(false, false, true, 50)] - [BindColumn("ClassName", "样式名称", "nvarchar(50)")] + [BindColumn("ClassName", "样式名称", "")] public String ClassName { get { return _ClassName; } set { if (OnPropertyChanging(__.ClassName, value)) { _ClassName = value; OnPropertyChanged(__.ClassName); } } } private String _BannerImg; @@ -236,7 +236,7 @@ namespace COMCMS.Core [DisplayName("banner图片")] [Description("banner图片")] [DataObjectField(false, false, true, 250)] - [BindColumn("BannerImg", "banner图片", "nvarchar(250)")] + [BindColumn("BannerImg", "banner图片", "")] public String BannerImg { get { return _BannerImg; } set { if (OnPropertyChanging(__.BannerImg, value)) { _BannerImg = value; OnPropertyChanged(__.BannerImg); } } } private String _KindInfo; @@ -244,7 +244,7 @@ namespace COMCMS.Core [DisplayName("栏目详细介绍")] [Description("栏目详细介绍")] [DataObjectField(false, false, true, -1)] - [BindColumn("KindInfo", "栏目详细介绍", "ntext")] + [BindColumn("KindInfo", "栏目详细介绍", "")] public String KindInfo { get { return _KindInfo; } set { if (OnPropertyChanging(__.KindInfo, value)) { _KindInfo = value; OnPropertyChanged(__.KindInfo); } } } private String _Pic; @@ -252,7 +252,7 @@ namespace COMCMS.Core [DisplayName("图片")] [Description("图片")] [DataObjectField(false, false, true, 250)] - [BindColumn("Pic", "图片", "nvarchar(250)")] + [BindColumn("Pic", "图片", "")] public String Pic { get { return _Pic; } set { if (OnPropertyChanging(__.Pic, value)) { _Pic = value; OnPropertyChanged(__.Pic); } } } private Int32 _AdsId; @@ -260,8 +260,16 @@ namespace COMCMS.Core [DisplayName("广告ID")] [Description("广告ID")] [DataObjectField(false, false, false, 0)] - [BindColumn("AdsId", "广告ID", "int")] + [BindColumn("AdsId", "广告ID", "")] public Int32 AdsId { get { return _AdsId; } set { if (OnPropertyChanging(__.AdsId, value)) { _AdsId = value; OnPropertyChanged(__.AdsId); } } } + + private String _FilePath; + /// 目录路径 + [DisplayName("目录路径")] + [Description("目录路径")] + [DataObjectField(false, false, true, 100)] + [BindColumn("FilePath", "目录路径", "")] + public String FilePath { get { return _FilePath; } set { if (OnPropertyChanging(__.FilePath, value)) { _FilePath = value; OnPropertyChanged(__.FilePath); } } } #endregion #region 获取/设置 字段值 @@ -305,6 +313,7 @@ namespace COMCMS.Core case __.KindInfo : return _KindInfo; case __.Pic : return _Pic; case __.AdsId : return _AdsId; + case __.FilePath : return _FilePath; default: return base[name]; } } @@ -312,7 +321,7 @@ namespace COMCMS.Core { switch (name) { - case __.Id : _Id = Convert.ToInt32(value); break; + case __.Id : _Id = value.ToInt(); break; case __.KindName : _KindName = Convert.ToString(value); break; case __.SubTitle : _SubTitle = Convert.ToString(value); break; case __.KindTitle : _KindTitle = Convert.ToString(value); break; @@ -323,26 +332,27 @@ namespace COMCMS.Core case __.TemplateFile : _TemplateFile = Convert.ToString(value); break; case __.DetailTemplateFile : _DetailTemplateFile = Convert.ToString(value); break; case __.KindDomain : _KindDomain = Convert.ToString(value); break; - case __.IsList : _IsList = Convert.ToInt32(value); break; - case __.PageSize : _PageSize = Convert.ToInt32(value); break; - case __.PId : _PId = Convert.ToInt32(value); break; - case __.Level : _Level = Convert.ToInt32(value); break; + case __.IsList : _IsList = value.ToInt(); break; + case __.PageSize : _PageSize = value.ToInt(); break; + case __.PId : _PId = value.ToInt(); break; + case __.Level : _Level = value.ToInt(); break; case __.Location : _Location = Convert.ToString(value); break; - case __.IsHide : _IsHide = Convert.ToInt32(value); break; - case __.IsLock : _IsLock = Convert.ToInt32(value); break; - case __.IsDel : _IsDel = Convert.ToInt32(value); break; - case __.IsComment : _IsComment = Convert.ToInt32(value); break; - case __.IsMember : _IsMember = Convert.ToInt32(value); break; - case __.IsShowSubDetail : _IsShowSubDetail = Convert.ToInt32(value); break; - case __.CatalogId : _CatalogId = Convert.ToInt32(value); break; - case __.Counts : _Counts = Convert.ToInt32(value); break; - case __.Rank : _Rank = Convert.ToInt32(value); break; + case __.IsHide : _IsHide = value.ToInt(); break; + case __.IsLock : _IsLock = value.ToInt(); break; + case __.IsDel : _IsDel = value.ToInt(); break; + case __.IsComment : _IsComment = value.ToInt(); break; + case __.IsMember : _IsMember = value.ToInt(); break; + case __.IsShowSubDetail : _IsShowSubDetail = value.ToInt(); break; + case __.CatalogId : _CatalogId = value.ToInt(); break; + case __.Counts : _Counts = value.ToInt(); break; + case __.Rank : _Rank = value.ToInt(); break; case __.Icon : _Icon = Convert.ToString(value); break; case __.ClassName : _ClassName = Convert.ToString(value); break; case __.BannerImg : _BannerImg = Convert.ToString(value); break; case __.KindInfo : _KindInfo = Convert.ToString(value); break; case __.Pic : _Pic = Convert.ToString(value); break; - case __.AdsId : _AdsId = Convert.ToInt32(value); break; + case __.AdsId : _AdsId = value.ToInt(); break; + case __.FilePath : _FilePath = Convert.ToString(value); break; default: base[name] = value; break; } } @@ -446,6 +456,9 @@ namespace COMCMS.Core /// 广告ID public static readonly Field AdsId = FindByName(__.AdsId); + /// 目录路径 + public static readonly Field FilePath = FindByName(__.FilePath); + static Field FindByName(String name) { return Meta.Table.FindByName(name); } } @@ -544,6 +557,9 @@ namespace COMCMS.Core /// 广告ID public const String AdsId = "AdsId"; + + /// 目录路径 + public const String FilePath = "FilePath"; } #endregion } @@ -644,6 +660,9 @@ namespace COMCMS.Core /// 广告ID Int32 AdsId { get; set; } + + /// 目录路径 + String FilePath { get; set; } #endregion #region 获取/设置 字段值 diff --git a/COMCMS.Core/COMCMS.Core.csproj b/COMCMS.Core/COMCMS.Core.csproj index 9017645..52d92fd 100644 --- a/COMCMS.Core/COMCMS.Core.csproj +++ b/COMCMS.Core/COMCMS.Core.csproj @@ -1,22 +1,16 @@ - + - netcoreapp2.1 + netcoreapp3.1 - - + + - - - C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.authentication.cookies\2.1.1\lib\netstandard2.0\Microsoft.AspNetCore.Authentication.Cookies.dll - - - diff --git a/COMCMS.Core/Core/广告详情.Biz.cs b/COMCMS.Core/Core/广告详情.Biz.cs index 940ec37..a1649cf 100644 --- a/COMCMS.Core/Core/广告详情.Biz.cs +++ b/COMCMS.Core/Core/广告详情.Biz.cs @@ -305,7 +305,7 @@ namespace COMCMS.Core { Ads model = new Ads(); model = Find(_.Id == aid); - if (model.TId == 4) + if (model!=null && model.TId == 4) { List listimg = new List(); listimg = JsonConvert.DeserializeObject>(model.Content); diff --git a/COMCMS.Core/Core/管理员.Biz.cs b/COMCMS.Core/Core/管理员.Biz.cs index bdca1ad..ddf17f2 100644 --- a/COMCMS.Core/Core/管理员.Biz.cs +++ b/COMCMS.Core/Core/管理员.Biz.cs @@ -184,8 +184,8 @@ namespace COMCMS.Core { if (IsAdminLogin()) { - //return Find(_.UserName == SessionHelper.GetSession(sessionAdminNameKey).ToString()); - return Find(_.UserName == AuthenticationHelper.GetClaim(sessionAdminNameKey)); + return Find(_.UserName == SessionHelper.GetSession(sessionAdminNameKey).ToString()); + //return Find(_.UserName == AuthenticationHelper.GetClaim(sessionAdminNameKey)); } else @@ -241,8 +241,8 @@ namespace COMCMS.Core //写入Session 和 Cookies //SessionHelper.WriteSession("rtadminguid", GUID.ToString()); //CookiesHelper.WriteCookie("rtadminguid", GUID.ToString(), 120); - //SetAdminInfo(entity.UserName, entity.PassWord, entity.Id, 0, "", GUID.ToString(), entity.Salt); - SetAdminInfoAsync(entity.UserName, entity.PassWord, entity.Id, 0, "", GUID.ToString(), entity.Salt).Wait(); + SetAdminInfo(entity.UserName, entity.PassWord, entity.Id, 0, "", GUID.ToString(), entity.Salt); + //SetAdminInfoAsync(entity.UserName, entity.PassWord, entity.Id, 0, "", GUID.ToString(), entity.Salt).Wait(); return true; } @@ -255,22 +255,22 @@ namespace COMCMS.Core /// 是否登录 public static bool IsAdminLogin() { - //string adminName = SessionHelper.GetSession(sessionAdminNameKey).ToString();//用户名 - //string adminID = SessionHelper.GetSession(sessionAdminIDKey).ToString();//ID - string adminName = AuthenticationHelper.GetClaim(sessionAdminNameKey);//用户名 - string adminID = AuthenticationHelper.GetClaim(sessionAdminIDKey);//ID + string adminName = SessionHelper.GetSession(sessionAdminNameKey).ToString();//用户名 + string adminID = SessionHelper.GetSession(sessionAdminIDKey).ToString();//ID + //string adminName = AuthenticationHelper.GetClaim(sessionAdminNameKey);//用户名 + //string adminID = AuthenticationHelper.GetClaim(sessionAdminIDKey);//ID //如果Session失效,则用Cookies判断 if (string.IsNullOrEmpty(adminName) || string.IsNullOrEmpty(adminID)) { - //string cooAdminName = CookiesHelper.GetCookie(cookiesAdminNameKey);//用户名 - //string cooAdminID = CookiesHelper.GetCookie(cookiesAdminIDKey);//ID - //string cooLoginInfo = CookiesHelper.GetCookie(cookiesAdminInfoKey);//信息 - //string cooAdminLogID = CookiesHelper.GetCookie(cookiesAdminLogIDKey);//日志GUID - string cooAdminName = AuthenticationHelper.GetClaim(cookiesAdminNameKey);//用户名 - string cooAdminID = AuthenticationHelper.GetClaim(cookiesAdminIDKey);//ID - string cooLoginInfo = AuthenticationHelper.GetClaim(cookiesAdminInfoKey);//信息 - string cooAdminLogID = AuthenticationHelper.GetClaim(cookiesAdminLogIDKey);//日志GUID + string cooAdminName = CookiesHelper.GetCookie(cookiesAdminNameKey);//用户名 + string cooAdminID = CookiesHelper.GetCookie(cookiesAdminIDKey);//ID + string cooLoginInfo = CookiesHelper.GetCookie(cookiesAdminInfoKey);//信息 + string cooAdminLogID = CookiesHelper.GetCookie(cookiesAdminLogIDKey);//日志GUID + //string cooAdminName = AuthenticationHelper.GetClaim(cookiesAdminNameKey);//用户名 + //string cooAdminID = AuthenticationHelper.GetClaim(cookiesAdminIDKey);//ID + //string cooLoginInfo = AuthenticationHelper.GetClaim(cookiesAdminInfoKey);//信息 + //string cooAdminLogID = AuthenticationHelper.GetClaim(cookiesAdminLogIDKey);//日志GUID if (string.IsNullOrEmpty(cooAdminID) || string.IsNullOrEmpty(cooAdminName) || string.IsNullOrEmpty(cooLoginInfo) || string.IsNullOrEmpty(cooAdminLogID)) { @@ -298,16 +298,16 @@ namespace COMCMS.Core } //重新写入Session 和 Cookies - //SetAdminInfo(model.UserName, model.PassWord, model.Id, 0, "", cooAdminLogID, model.Salt); + SetAdminInfo(model.UserName, model.PassWord, model.Id, 0, "", cooAdminLogID, model.Salt); - SetAdminInfoAsync(model.UserName, model.PassWord, model.Id, 0, "", cooAdminLogID, model.Salt).Wait(); + //SetAdminInfoAsync(model.UserName, model.PassWord, model.Id, 0, "", cooAdminLogID, model.Salt).Wait(); return true; } else { - //ClearInfo();//清除信息 - ClearInfoAsync().Wait(); + ClearInfo();//清除信息 + //ClearInfoAsync().Wait(); return false;//信息错误 } } diff --git a/COMCMS.Core/Mall/商品栏目.Biz.cs b/COMCMS.Core/Mall/商品栏目.Biz.cs index e107cb0..55a8e06 100644 --- a/COMCMS.Core/Mall/商品栏目.Biz.cs +++ b/COMCMS.Core/Mall/商品栏目.Biz.cs @@ -132,6 +132,22 @@ namespace COMCMS.Core return Find(_.Id == id); } + + /// 根据目录查找 + /// 目录 + /// 实体对象 + public static Category FindByFilePath(string path) + { + if (string.IsNullOrEmpty(path)) return null; + + // 实体缓存 + if (Meta.Count < 1000) return Meta.Cache.Find(e => e.FilePath == path); + + // 单对象缓存 + //return Meta.SingleCache[id]; + + return Find(_.FilePath == path); + } /// /// 根据父ID查询所有子项 /// diff --git a/COMCMS.Core/Mall/商品栏目.cs b/COMCMS.Core/Mall/商品栏目.cs index 52a1936..f1caf57 100644 --- a/COMCMS.Core/Mall/商品栏目.cs +++ b/COMCMS.Core/Mall/商品栏目.cs @@ -20,7 +20,7 @@ namespace COMCMS.Core [DisplayName("编号")] [Description("编号")] [DataObjectField(true, true, false, 0)] - [BindColumn("Id", "编号", "int")] + [BindColumn("Id", "编号", "")] public Int32 Id { get { return _Id; } set { if (OnPropertyChanging(__.Id, value)) { _Id = value; OnPropertyChanged(__.Id); } } } private String _KindName; @@ -28,7 +28,7 @@ namespace COMCMS.Core [DisplayName("栏目名称")] [Description("栏目名称")] [DataObjectField(false, false, true, 250)] - [BindColumn("KindName", "栏目名称", "nvarchar(250)")] + [BindColumn("KindName", "栏目名称", "")] public String KindName { get { return _KindName; } set { if (OnPropertyChanging(__.KindName, value)) { _KindName = value; OnPropertyChanged(__.KindName); } } } private String _SubTitle; @@ -36,7 +36,7 @@ namespace COMCMS.Core [DisplayName("栏目副标题")] [Description("栏目副标题")] [DataObjectField(false, false, true, 250)] - [BindColumn("SubTitle", "栏目副标题", "nvarchar(250)")] + [BindColumn("SubTitle", "栏目副标题", "")] public String SubTitle { get { return _SubTitle; } set { if (OnPropertyChanging(__.SubTitle, value)) { _SubTitle = value; OnPropertyChanged(__.SubTitle); } } } private String _KindTitle; @@ -44,7 +44,7 @@ namespace COMCMS.Core [DisplayName("栏目标题")] [Description("栏目标题,填写则在浏览器替换此标题")] [DataObjectField(false, false, true, 250)] - [BindColumn("KindTitle", "栏目标题,填写则在浏览器替换此标题", "nvarchar(250)")] + [BindColumn("KindTitle", "栏目标题,填写则在浏览器替换此标题", "")] public String KindTitle { get { return _KindTitle; } set { if (OnPropertyChanging(__.KindTitle, value)) { _KindTitle = value; OnPropertyChanged(__.KindTitle); } } } private String _Keyword; @@ -52,7 +52,7 @@ namespace COMCMS.Core [DisplayName("描述")] [Description("描述")] [DataObjectField(false, false, true, 250)] - [BindColumn("Keyword", "描述", "nvarchar(250)")] + [BindColumn("Keyword", "描述", "")] public String Keyword { get { return _Keyword; } set { if (OnPropertyChanging(__.Keyword, value)) { _Keyword = value; OnPropertyChanged(__.Keyword); } } } private String _Description; @@ -60,7 +60,7 @@ namespace COMCMS.Core [DisplayName("介绍")] [Description("介绍")] [DataObjectField(false, false, true, 250)] - [BindColumn("Description", "介绍", "nvarchar(250)")] + [BindColumn("Description", "介绍", "")] public String Description { get { return _Description; } set { if (OnPropertyChanging(__.Description, value)) { _Description = value; OnPropertyChanged(__.Description); } } } private String _LinkURL; @@ -68,7 +68,7 @@ namespace COMCMS.Core [DisplayName("跳转链接")] [Description("跳转链接")] [DataObjectField(false, false, true, 250)] - [BindColumn("LinkURL", "跳转链接", "nvarchar(250)")] + [BindColumn("LinkURL", "跳转链接", "")] public String LinkURL { get { return _LinkURL; } set { if (OnPropertyChanging(__.LinkURL, value)) { _LinkURL = value; OnPropertyChanged(__.LinkURL); } } } private String _TitleColor; @@ -76,7 +76,7 @@ namespace COMCMS.Core [DisplayName("类别名称颜色")] [Description("类别名称颜色")] [DataObjectField(false, false, true, 50)] - [BindColumn("TitleColor", "类别名称颜色", "nvarchar(50)")] + [BindColumn("TitleColor", "类别名称颜色", "")] public String TitleColor { get { return _TitleColor; } set { if (OnPropertyChanging(__.TitleColor, value)) { _TitleColor = value; OnPropertyChanged(__.TitleColor); } } } private String _TemplateFile; @@ -84,7 +84,7 @@ namespace COMCMS.Core [DisplayName("模板")] [Description("模板")] [DataObjectField(false, false, true, 250)] - [BindColumn("TemplateFile", "模板", "nvarchar(250)")] + [BindColumn("TemplateFile", "模板", "")] public String TemplateFile { get { return _TemplateFile; } set { if (OnPropertyChanging(__.TemplateFile, value)) { _TemplateFile = value; OnPropertyChanged(__.TemplateFile); } } } private String _DetailTemplateFile; @@ -92,7 +92,7 @@ namespace COMCMS.Core [DisplayName("详情模板")] [Description("详情模板")] [DataObjectField(false, false, true, 250)] - [BindColumn("DetailTemplateFile", "详情模板", "nvarchar(250)")] + [BindColumn("DetailTemplateFile", "详情模板", "")] public String DetailTemplateFile { get { return _DetailTemplateFile; } set { if (OnPropertyChanging(__.DetailTemplateFile, value)) { _DetailTemplateFile = value; OnPropertyChanged(__.DetailTemplateFile); } } } private String _KindDomain; @@ -100,7 +100,7 @@ namespace COMCMS.Core [DisplayName("类别域名")] [Description("类别域名(保留)")] [DataObjectField(false, false, true, 250)] - [BindColumn("KindDomain", "类别域名(保留)", "nvarchar(250)")] + [BindColumn("KindDomain", "类别域名(保留)", "")] public String KindDomain { get { return _KindDomain; } set { if (OnPropertyChanging(__.KindDomain, value)) { _KindDomain = value; OnPropertyChanged(__.KindDomain); } } } private Int32 _IsList; @@ -108,7 +108,7 @@ namespace COMCMS.Core [DisplayName("是否为列表页面")] [Description("是否为列表页面")] [DataObjectField(false, false, false, 0)] - [BindColumn("IsList", "是否为列表页面", "int")] + [BindColumn("IsList", "是否为列表页面", "")] public Int32 IsList { get { return _IsList; } set { if (OnPropertyChanging(__.IsList, value)) { _IsList = value; OnPropertyChanged(__.IsList); } } } private Int32 _PageSize; @@ -116,7 +116,7 @@ namespace COMCMS.Core [DisplayName("每页显示数量")] [Description("每页显示数量")] [DataObjectField(false, false, false, 0)] - [BindColumn("PageSize", "每页显示数量", "int")] + [BindColumn("PageSize", "每页显示数量", "")] public Int32 PageSize { get { return _PageSize; } set { if (OnPropertyChanging(__.PageSize, value)) { _PageSize = value; OnPropertyChanged(__.PageSize); } } } private Int32 _PId; @@ -124,7 +124,7 @@ namespace COMCMS.Core [DisplayName("上级ID")] [Description("上级ID")] [DataObjectField(false, false, false, 0)] - [BindColumn("PId", "上级ID", "int")] + [BindColumn("PId", "上级ID", "")] public Int32 PId { get { return _PId; } set { if (OnPropertyChanging(__.PId, value)) { _PId = value; OnPropertyChanged(__.PId); } } } private Int32 _Level; @@ -132,7 +132,7 @@ namespace COMCMS.Core [DisplayName("级别")] [Description("级别")] [DataObjectField(false, false, false, 0)] - [BindColumn("Level", "级别", "int")] + [BindColumn("Level", "级别", "")] public Int32 Level { get { return _Level; } set { if (OnPropertyChanging(__.Level, value)) { _Level = value; OnPropertyChanged(__.Level); } } } private String _Location; @@ -140,7 +140,7 @@ namespace COMCMS.Core [DisplayName("路径")] [Description("路径")] [DataObjectField(false, false, true, 100)] - [BindColumn("Location", "路径", "nvarchar(100)")] + [BindColumn("Location", "路径", "")] public String Location { get { return _Location; } set { if (OnPropertyChanging(__.Location, value)) { _Location = value; OnPropertyChanged(__.Location); } } } private Int32 _IsHide; @@ -148,7 +148,7 @@ namespace COMCMS.Core [DisplayName("是否隐藏")] [Description("是否隐藏")] [DataObjectField(false, false, false, 0)] - [BindColumn("IsHide", "是否隐藏", "int")] + [BindColumn("IsHide", "是否隐藏", "")] public Int32 IsHide { get { return _IsHide; } set { if (OnPropertyChanging(__.IsHide, value)) { _IsHide = value; OnPropertyChanged(__.IsHide); } } } private Int32 _IsLock; @@ -156,7 +156,7 @@ namespace COMCMS.Core [DisplayName("是否锁定")] [Description("是否锁定,不允许删除")] [DataObjectField(false, false, false, 0)] - [BindColumn("IsLock", "是否锁定,不允许删除", "int")] + [BindColumn("IsLock", "是否锁定,不允许删除", "")] public Int32 IsLock { get { return _IsLock; } set { if (OnPropertyChanging(__.IsLock, value)) { _IsLock = value; OnPropertyChanged(__.IsLock); } } } private Int32 _IsDel; @@ -164,7 +164,7 @@ namespace COMCMS.Core [DisplayName("是否删除")] [Description("是否删除,已经删除到回收站")] [DataObjectField(false, false, false, 0)] - [BindColumn("IsDel", "是否删除,已经删除到回收站", "int")] + [BindColumn("IsDel", "是否删除,已经删除到回收站", "")] public Int32 IsDel { get { return _IsDel; } set { if (OnPropertyChanging(__.IsDel, value)) { _IsDel = value; OnPropertyChanged(__.IsDel); } } } private Int32 _IsComment; @@ -172,7 +172,7 @@ namespace COMCMS.Core [DisplayName("是否允许评论")] [Description("是否允许评论")] [DataObjectField(false, false, false, 0)] - [BindColumn("IsComment", "是否允许评论", "int")] + [BindColumn("IsComment", "是否允许评论", "")] public Int32 IsComment { get { return _IsComment; } set { if (OnPropertyChanging(__.IsComment, value)) { _IsComment = value; OnPropertyChanged(__.IsComment); } } } private Int32 _IsMember; @@ -180,7 +180,7 @@ namespace COMCMS.Core [DisplayName("是否会员栏目")] [Description("是否会员栏目")] [DataObjectField(false, false, false, 0)] - [BindColumn("IsMember", "是否会员栏目", "int")] + [BindColumn("IsMember", "是否会员栏目", "")] public Int32 IsMember { get { return _IsMember; } set { if (OnPropertyChanging(__.IsMember, value)) { _IsMember = value; OnPropertyChanged(__.IsMember); } } } private Int32 _IsShowSubDetail; @@ -188,7 +188,7 @@ namespace COMCMS.Core [DisplayName("是否显示下级栏目内容")] [Description("是否显示下级栏目内容")] [DataObjectField(false, false, false, 0)] - [BindColumn("IsShowSubDetail", "是否显示下级栏目内容", "int")] + [BindColumn("IsShowSubDetail", "是否显示下级栏目内容", "")] public Int32 IsShowSubDetail { get { return _IsShowSubDetail; } set { if (OnPropertyChanging(__.IsShowSubDetail, value)) { _IsShowSubDetail = value; OnPropertyChanged(__.IsShowSubDetail); } } } private Int32 _CatalogId; @@ -196,7 +196,7 @@ namespace COMCMS.Core [DisplayName("模型ID")] [Description("模型ID")] [DataObjectField(false, false, false, 0)] - [BindColumn("CatalogId", "模型ID", "int")] + [BindColumn("CatalogId", "模型ID", "")] public Int32 CatalogId { get { return _CatalogId; } set { if (OnPropertyChanging(__.CatalogId, value)) { _CatalogId = value; OnPropertyChanged(__.CatalogId); } } } private Int32 _Counts; @@ -204,7 +204,7 @@ namespace COMCMS.Core [DisplayName("详情数量")] [Description("详情数量,缓存")] [DataObjectField(false, false, false, 0)] - [BindColumn("Counts", "详情数量,缓存", "int")] + [BindColumn("Counts", "详情数量,缓存", "")] public Int32 Counts { get { return _Counts; } set { if (OnPropertyChanging(__.Counts, value)) { _Counts = value; OnPropertyChanged(__.Counts); } } } private Int32 _Rank; @@ -212,7 +212,7 @@ namespace COMCMS.Core [DisplayName("排序")] [Description("排序")] [DataObjectField(false, false, false, 0)] - [BindColumn("Rank", "排序", "int")] + [BindColumn("Rank", "排序", "")] public Int32 Rank { get { return _Rank; } set { if (OnPropertyChanging(__.Rank, value)) { _Rank = value; OnPropertyChanged(__.Rank); } } } private String _Icon; @@ -220,7 +220,7 @@ namespace COMCMS.Core [DisplayName("图标")] [Description("图标")] [DataObjectField(false, false, true, 100)] - [BindColumn("Icon", "图标", "nvarchar(100)")] + [BindColumn("Icon", "图标", "")] public String Icon { get { return _Icon; } set { if (OnPropertyChanging(__.Icon, value)) { _Icon = value; OnPropertyChanged(__.Icon); } } } private String _ClassName; @@ -228,7 +228,7 @@ namespace COMCMS.Core [DisplayName("样式名称")] [Description("样式名称")] [DataObjectField(false, false, true, 50)] - [BindColumn("ClassName", "样式名称", "nvarchar(50)")] + [BindColumn("ClassName", "样式名称", "")] public String ClassName { get { return _ClassName; } set { if (OnPropertyChanging(__.ClassName, value)) { _ClassName = value; OnPropertyChanged(__.ClassName); } } } private String _BannerImg; @@ -236,7 +236,7 @@ namespace COMCMS.Core [DisplayName("banner图片")] [Description("banner图片")] [DataObjectField(false, false, true, 250)] - [BindColumn("BannerImg", "banner图片", "nvarchar(250)")] + [BindColumn("BannerImg", "banner图片", "")] public String BannerImg { get { return _BannerImg; } set { if (OnPropertyChanging(__.BannerImg, value)) { _BannerImg = value; OnPropertyChanged(__.BannerImg); } } } private String _KindInfo; @@ -244,7 +244,7 @@ namespace COMCMS.Core [DisplayName("栏目详细介绍")] [Description("栏目详细介绍")] [DataObjectField(false, false, true, -1)] - [BindColumn("KindInfo", "栏目详细介绍", "ntext")] + [BindColumn("KindInfo", "栏目详细介绍", "")] public String KindInfo { get { return _KindInfo; } set { if (OnPropertyChanging(__.KindInfo, value)) { _KindInfo = value; OnPropertyChanged(__.KindInfo); } } } private String _Pic; @@ -252,7 +252,7 @@ namespace COMCMS.Core [DisplayName("图片")] [Description("图片")] [DataObjectField(false, false, true, 250)] - [BindColumn("Pic", "图片", "nvarchar(250)")] + [BindColumn("Pic", "图片", "")] public String Pic { get { return _Pic; } set { if (OnPropertyChanging(__.Pic, value)) { _Pic = value; OnPropertyChanged(__.Pic); } } } private Int32 _AdsId; @@ -260,8 +260,16 @@ namespace COMCMS.Core [DisplayName("广告ID")] [Description("广告ID")] [DataObjectField(false, false, false, 0)] - [BindColumn("AdsId", "广告ID", "int")] + [BindColumn("AdsId", "广告ID", "")] public Int32 AdsId { get { return _AdsId; } set { if (OnPropertyChanging(__.AdsId, value)) { _AdsId = value; OnPropertyChanged(__.AdsId); } } } + + private String _FilePath; + /// 目录路径 + [DisplayName("目录路径")] + [Description("目录路径")] + [DataObjectField(false, false, true, 100)] + [BindColumn("FilePath", "目录路径", "")] + public String FilePath { get { return _FilePath; } set { if (OnPropertyChanging(__.FilePath, value)) { _FilePath = value; OnPropertyChanged(__.FilePath); } } } #endregion #region 获取/设置 字段值 @@ -305,6 +313,7 @@ namespace COMCMS.Core case __.KindInfo : return _KindInfo; case __.Pic : return _Pic; case __.AdsId : return _AdsId; + case __.FilePath : return _FilePath; default: return base[name]; } } @@ -312,7 +321,7 @@ namespace COMCMS.Core { switch (name) { - case __.Id : _Id = Convert.ToInt32(value); break; + case __.Id : _Id = value.ToInt(); break; case __.KindName : _KindName = Convert.ToString(value); break; case __.SubTitle : _SubTitle = Convert.ToString(value); break; case __.KindTitle : _KindTitle = Convert.ToString(value); break; @@ -323,26 +332,27 @@ namespace COMCMS.Core case __.TemplateFile : _TemplateFile = Convert.ToString(value); break; case __.DetailTemplateFile : _DetailTemplateFile = Convert.ToString(value); break; case __.KindDomain : _KindDomain = Convert.ToString(value); break; - case __.IsList : _IsList = Convert.ToInt32(value); break; - case __.PageSize : _PageSize = Convert.ToInt32(value); break; - case __.PId : _PId = Convert.ToInt32(value); break; - case __.Level : _Level = Convert.ToInt32(value); break; + case __.IsList : _IsList = value.ToInt(); break; + case __.PageSize : _PageSize = value.ToInt(); break; + case __.PId : _PId = value.ToInt(); break; + case __.Level : _Level = value.ToInt(); break; case __.Location : _Location = Convert.ToString(value); break; - case __.IsHide : _IsHide = Convert.ToInt32(value); break; - case __.IsLock : _IsLock = Convert.ToInt32(value); break; - case __.IsDel : _IsDel = Convert.ToInt32(value); break; - case __.IsComment : _IsComment = Convert.ToInt32(value); break; - case __.IsMember : _IsMember = Convert.ToInt32(value); break; - case __.IsShowSubDetail : _IsShowSubDetail = Convert.ToInt32(value); break; - case __.CatalogId : _CatalogId = Convert.ToInt32(value); break; - case __.Counts : _Counts = Convert.ToInt32(value); break; - case __.Rank : _Rank = Convert.ToInt32(value); break; + case __.IsHide : _IsHide = value.ToInt(); break; + case __.IsLock : _IsLock = value.ToInt(); break; + case __.IsDel : _IsDel = value.ToInt(); break; + case __.IsComment : _IsComment = value.ToInt(); break; + case __.IsMember : _IsMember = value.ToInt(); break; + case __.IsShowSubDetail : _IsShowSubDetail = value.ToInt(); break; + case __.CatalogId : _CatalogId = value.ToInt(); break; + case __.Counts : _Counts = value.ToInt(); break; + case __.Rank : _Rank = value.ToInt(); break; case __.Icon : _Icon = Convert.ToString(value); break; case __.ClassName : _ClassName = Convert.ToString(value); break; case __.BannerImg : _BannerImg = Convert.ToString(value); break; case __.KindInfo : _KindInfo = Convert.ToString(value); break; case __.Pic : _Pic = Convert.ToString(value); break; - case __.AdsId : _AdsId = Convert.ToInt32(value); break; + case __.AdsId : _AdsId = value.ToInt(); break; + case __.FilePath : _FilePath = Convert.ToString(value); break; default: base[name] = value; break; } } @@ -446,6 +456,9 @@ namespace COMCMS.Core /// 广告ID public static readonly Field AdsId = FindByName(__.AdsId); + /// 目录路径 + public static readonly Field FilePath = FindByName(__.FilePath); + static Field FindByName(String name) { return Meta.Table.FindByName(name); } } @@ -544,6 +557,9 @@ namespace COMCMS.Core /// 广告ID public const String AdsId = "AdsId"; + + /// 目录路径 + public const String FilePath = "FilePath"; } #endregion } @@ -644,6 +660,9 @@ namespace COMCMS.Core /// 广告ID Int32 AdsId { get; set; } + + /// 目录路径 + String FilePath { get; set; } #endregion #region 获取/设置 字段值 diff --git a/COMCMS.Core/Mall/商家分类.cs b/COMCMS.Core/Mall/商家分类.cs index 36c4227..8e580d8 100644 --- a/COMCMS.Core/Mall/商家分类.cs +++ b/COMCMS.Core/Mall/商家分类.cs @@ -20,7 +20,7 @@ namespace COMCMS.Core [DisplayName("编号")] [Description("编号")] [DataObjectField(true, true, false, 0)] - [BindColumn("Id", "编号", "int")] + [BindColumn("Id", "编号", "")] public Int32 Id { get { return _Id; } set { if (OnPropertyChanging(__.Id, value)) { _Id = value; OnPropertyChanged(__.Id); } } } private String _KindName; @@ -28,7 +28,7 @@ namespace COMCMS.Core [DisplayName("栏目名称")] [Description("栏目名称")] [DataObjectField(false, false, true, 250)] - [BindColumn("KindName", "栏目名称", "nvarchar(250)")] + [BindColumn("KindName", "栏目名称", "")] public String KindName { get { return _KindName; } set { if (OnPropertyChanging(__.KindName, value)) { _KindName = value; OnPropertyChanged(__.KindName); } } } private String _SubTitle; @@ -36,7 +36,7 @@ namespace COMCMS.Core [DisplayName("栏目副标题")] [Description("栏目副标题")] [DataObjectField(false, false, true, 250)] - [BindColumn("SubTitle", "栏目副标题", "nvarchar(250)")] + [BindColumn("SubTitle", "栏目副标题", "")] public String SubTitle { get { return _SubTitle; } set { if (OnPropertyChanging(__.SubTitle, value)) { _SubTitle = value; OnPropertyChanged(__.SubTitle); } } } private String _KindTitle; @@ -44,7 +44,7 @@ namespace COMCMS.Core [DisplayName("栏目标题")] [Description("栏目标题,填写则在浏览器替换此标题")] [DataObjectField(false, false, true, 250)] - [BindColumn("KindTitle", "栏目标题,填写则在浏览器替换此标题", "nvarchar(250)")] + [BindColumn("KindTitle", "栏目标题,填写则在浏览器替换此标题", "")] public String KindTitle { get { return _KindTitle; } set { if (OnPropertyChanging(__.KindTitle, value)) { _KindTitle = value; OnPropertyChanged(__.KindTitle); } } } private String _Keyword; @@ -52,7 +52,7 @@ namespace COMCMS.Core [DisplayName("描述")] [Description("描述")] [DataObjectField(false, false, true, 250)] - [BindColumn("Keyword", "描述", "nvarchar(250)")] + [BindColumn("Keyword", "描述", "")] public String Keyword { get { return _Keyword; } set { if (OnPropertyChanging(__.Keyword, value)) { _Keyword = value; OnPropertyChanged(__.Keyword); } } } private String _Description; @@ -60,7 +60,7 @@ namespace COMCMS.Core [DisplayName("介绍")] [Description("介绍")] [DataObjectField(false, false, true, 250)] - [BindColumn("Description", "介绍", "nvarchar(250)")] + [BindColumn("Description", "介绍", "")] public String Description { get { return _Description; } set { if (OnPropertyChanging(__.Description, value)) { _Description = value; OnPropertyChanged(__.Description); } } } private String _LinkURL; @@ -68,7 +68,7 @@ namespace COMCMS.Core [DisplayName("跳转链接")] [Description("跳转链接")] [DataObjectField(false, false, true, 250)] - [BindColumn("LinkURL", "跳转链接", "nvarchar(250)")] + [BindColumn("LinkURL", "跳转链接", "")] public String LinkURL { get { return _LinkURL; } set { if (OnPropertyChanging(__.LinkURL, value)) { _LinkURL = value; OnPropertyChanged(__.LinkURL); } } } private String _TitleColor; @@ -76,7 +76,7 @@ namespace COMCMS.Core [DisplayName("类别名称颜色")] [Description("类别名称颜色")] [DataObjectField(false, false, true, 50)] - [BindColumn("TitleColor", "类别名称颜色", "nvarchar(50)")] + [BindColumn("TitleColor", "类别名称颜色", "")] public String TitleColor { get { return _TitleColor; } set { if (OnPropertyChanging(__.TitleColor, value)) { _TitleColor = value; OnPropertyChanged(__.TitleColor); } } } private String _TemplateFile; @@ -84,7 +84,7 @@ namespace COMCMS.Core [DisplayName("模板")] [Description("模板")] [DataObjectField(false, false, true, 250)] - [BindColumn("TemplateFile", "模板", "nvarchar(250)")] + [BindColumn("TemplateFile", "模板", "")] public String TemplateFile { get { return _TemplateFile; } set { if (OnPropertyChanging(__.TemplateFile, value)) { _TemplateFile = value; OnPropertyChanged(__.TemplateFile); } } } private String _DetailTemplateFile; @@ -92,7 +92,7 @@ namespace COMCMS.Core [DisplayName("详情模板")] [Description("详情模板")] [DataObjectField(false, false, true, 250)] - [BindColumn("DetailTemplateFile", "详情模板", "nvarchar(250)")] + [BindColumn("DetailTemplateFile", "详情模板", "")] public String DetailTemplateFile { get { return _DetailTemplateFile; } set { if (OnPropertyChanging(__.DetailTemplateFile, value)) { _DetailTemplateFile = value; OnPropertyChanged(__.DetailTemplateFile); } } } private String _KindDomain; @@ -100,7 +100,7 @@ namespace COMCMS.Core [DisplayName("类别域名")] [Description("类别域名(保留)")] [DataObjectField(false, false, true, 250)] - [BindColumn("KindDomain", "类别域名(保留)", "nvarchar(250)")] + [BindColumn("KindDomain", "类别域名(保留)", "")] public String KindDomain { get { return _KindDomain; } set { if (OnPropertyChanging(__.KindDomain, value)) { _KindDomain = value; OnPropertyChanged(__.KindDomain); } } } private Int32 _IsList; @@ -108,7 +108,7 @@ namespace COMCMS.Core [DisplayName("是否为列表页面")] [Description("是否为列表页面")] [DataObjectField(false, false, false, 0)] - [BindColumn("IsList", "是否为列表页面", "int")] + [BindColumn("IsList", "是否为列表页面", "")] public Int32 IsList { get { return _IsList; } set { if (OnPropertyChanging(__.IsList, value)) { _IsList = value; OnPropertyChanged(__.IsList); } } } private Int32 _PageSize; @@ -116,7 +116,7 @@ namespace COMCMS.Core [DisplayName("每页显示数量")] [Description("每页显示数量")] [DataObjectField(false, false, false, 0)] - [BindColumn("PageSize", "每页显示数量", "int")] + [BindColumn("PageSize", "每页显示数量", "")] public Int32 PageSize { get { return _PageSize; } set { if (OnPropertyChanging(__.PageSize, value)) { _PageSize = value; OnPropertyChanged(__.PageSize); } } } private Int32 _PId; @@ -124,7 +124,7 @@ namespace COMCMS.Core [DisplayName("上级ID")] [Description("上级ID")] [DataObjectField(false, false, false, 0)] - [BindColumn("PId", "上级ID", "int")] + [BindColumn("PId", "上级ID", "")] public Int32 PId { get { return _PId; } set { if (OnPropertyChanging(__.PId, value)) { _PId = value; OnPropertyChanged(__.PId); } } } private Int32 _Level; @@ -132,7 +132,7 @@ namespace COMCMS.Core [DisplayName("级别")] [Description("级别")] [DataObjectField(false, false, false, 0)] - [BindColumn("Level", "级别", "int")] + [BindColumn("Level", "级别", "")] public Int32 Level { get { return _Level; } set { if (OnPropertyChanging(__.Level, value)) { _Level = value; OnPropertyChanged(__.Level); } } } private String _Location; @@ -140,7 +140,7 @@ namespace COMCMS.Core [DisplayName("路径")] [Description("路径")] [DataObjectField(false, false, true, 100)] - [BindColumn("Location", "路径", "nvarchar(100)")] + [BindColumn("Location", "路径", "")] public String Location { get { return _Location; } set { if (OnPropertyChanging(__.Location, value)) { _Location = value; OnPropertyChanged(__.Location); } } } private Int32 _IsHide; @@ -148,7 +148,7 @@ namespace COMCMS.Core [DisplayName("是否隐藏")] [Description("是否隐藏")] [DataObjectField(false, false, false, 0)] - [BindColumn("IsHide", "是否隐藏", "int")] + [BindColumn("IsHide", "是否隐藏", "")] public Int32 IsHide { get { return _IsHide; } set { if (OnPropertyChanging(__.IsHide, value)) { _IsHide = value; OnPropertyChanged(__.IsHide); } } } private Int32 _IsLock; @@ -156,7 +156,7 @@ namespace COMCMS.Core [DisplayName("是否锁定")] [Description("是否锁定,不允许删除")] [DataObjectField(false, false, false, 0)] - [BindColumn("IsLock", "是否锁定,不允许删除", "int")] + [BindColumn("IsLock", "是否锁定,不允许删除", "")] public Int32 IsLock { get { return _IsLock; } set { if (OnPropertyChanging(__.IsLock, value)) { _IsLock = value; OnPropertyChanged(__.IsLock); } } } private Int32 _IsDel; @@ -164,7 +164,7 @@ namespace COMCMS.Core [DisplayName("是否删除")] [Description("是否删除,已经删除到回收站")] [DataObjectField(false, false, false, 0)] - [BindColumn("IsDel", "是否删除,已经删除到回收站", "int")] + [BindColumn("IsDel", "是否删除,已经删除到回收站", "")] public Int32 IsDel { get { return _IsDel; } set { if (OnPropertyChanging(__.IsDel, value)) { _IsDel = value; OnPropertyChanged(__.IsDel); } } } private Int32 _IsComment; @@ -172,7 +172,7 @@ namespace COMCMS.Core [DisplayName("是否允许评论")] [Description("是否允许评论")] [DataObjectField(false, false, false, 0)] - [BindColumn("IsComment", "是否允许评论", "int")] + [BindColumn("IsComment", "是否允许评论", "")] public Int32 IsComment { get { return _IsComment; } set { if (OnPropertyChanging(__.IsComment, value)) { _IsComment = value; OnPropertyChanged(__.IsComment); } } } private Int32 _IsMember; @@ -180,7 +180,7 @@ namespace COMCMS.Core [DisplayName("是否会员栏目")] [Description("是否会员栏目")] [DataObjectField(false, false, false, 0)] - [BindColumn("IsMember", "是否会员栏目", "int")] + [BindColumn("IsMember", "是否会员栏目", "")] public Int32 IsMember { get { return _IsMember; } set { if (OnPropertyChanging(__.IsMember, value)) { _IsMember = value; OnPropertyChanged(__.IsMember); } } } private Int32 _IsShowSubDetail; @@ -188,7 +188,7 @@ namespace COMCMS.Core [DisplayName("是否显示下级栏目内容")] [Description("是否显示下级栏目内容")] [DataObjectField(false, false, false, 0)] - [BindColumn("IsShowSubDetail", "是否显示下级栏目内容", "int")] + [BindColumn("IsShowSubDetail", "是否显示下级栏目内容", "")] public Int32 IsShowSubDetail { get { return _IsShowSubDetail; } set { if (OnPropertyChanging(__.IsShowSubDetail, value)) { _IsShowSubDetail = value; OnPropertyChanged(__.IsShowSubDetail); } } } private Int32 _CatalogId; @@ -196,7 +196,7 @@ namespace COMCMS.Core [DisplayName("模型ID")] [Description("模型ID")] [DataObjectField(false, false, false, 0)] - [BindColumn("CatalogId", "模型ID", "int")] + [BindColumn("CatalogId", "模型ID", "")] public Int32 CatalogId { get { return _CatalogId; } set { if (OnPropertyChanging(__.CatalogId, value)) { _CatalogId = value; OnPropertyChanged(__.CatalogId); } } } private Int32 _Counts; @@ -204,7 +204,7 @@ namespace COMCMS.Core [DisplayName("详情数量")] [Description("详情数量,缓存")] [DataObjectField(false, false, false, 0)] - [BindColumn("Counts", "详情数量,缓存", "int")] + [BindColumn("Counts", "详情数量,缓存", "")] public Int32 Counts { get { return _Counts; } set { if (OnPropertyChanging(__.Counts, value)) { _Counts = value; OnPropertyChanged(__.Counts); } } } private Int32 _Rank; @@ -212,7 +212,7 @@ namespace COMCMS.Core [DisplayName("排序")] [Description("排序")] [DataObjectField(false, false, false, 0)] - [BindColumn("Rank", "排序", "int")] + [BindColumn("Rank", "排序", "")] public Int32 Rank { get { return _Rank; } set { if (OnPropertyChanging(__.Rank, value)) { _Rank = value; OnPropertyChanged(__.Rank); } } } private String _Icon; @@ -220,7 +220,7 @@ namespace COMCMS.Core [DisplayName("图标")] [Description("图标")] [DataObjectField(false, false, true, 100)] - [BindColumn("Icon", "图标", "nvarchar(100)")] + [BindColumn("Icon", "图标", "")] public String Icon { get { return _Icon; } set { if (OnPropertyChanging(__.Icon, value)) { _Icon = value; OnPropertyChanged(__.Icon); } } } private String _ClassName; @@ -228,7 +228,7 @@ namespace COMCMS.Core [DisplayName("样式名称")] [Description("样式名称")] [DataObjectField(false, false, true, 50)] - [BindColumn("ClassName", "样式名称", "nvarchar(50)")] + [BindColumn("ClassName", "样式名称", "")] public String ClassName { get { return _ClassName; } set { if (OnPropertyChanging(__.ClassName, value)) { _ClassName = value; OnPropertyChanged(__.ClassName); } } } private String _BannerImg; @@ -236,7 +236,7 @@ namespace COMCMS.Core [DisplayName("banner图片")] [Description("banner图片")] [DataObjectField(false, false, true, 250)] - [BindColumn("BannerImg", "banner图片", "nvarchar(250)")] + [BindColumn("BannerImg", "banner图片", "")] public String BannerImg { get { return _BannerImg; } set { if (OnPropertyChanging(__.BannerImg, value)) { _BannerImg = value; OnPropertyChanged(__.BannerImg); } } } private String _KindInfo; @@ -244,7 +244,7 @@ namespace COMCMS.Core [DisplayName("栏目详细介绍")] [Description("栏目详细介绍")] [DataObjectField(false, false, true, -1)] - [BindColumn("KindInfo", "栏目详细介绍", "ntext")] + [BindColumn("KindInfo", "栏目详细介绍", "")] public String KindInfo { get { return _KindInfo; } set { if (OnPropertyChanging(__.KindInfo, value)) { _KindInfo = value; OnPropertyChanged(__.KindInfo); } } } private String _Pic; @@ -252,7 +252,7 @@ namespace COMCMS.Core [DisplayName("图片")] [Description("图片")] [DataObjectField(false, false, true, 250)] - [BindColumn("Pic", "图片", "nvarchar(250)")] + [BindColumn("Pic", "图片", "")] public String Pic { get { return _Pic; } set { if (OnPropertyChanging(__.Pic, value)) { _Pic = value; OnPropertyChanged(__.Pic); } } } private Int32 _AdsId; @@ -260,7 +260,7 @@ namespace COMCMS.Core [DisplayName("广告ID")] [Description("广告ID")] [DataObjectField(false, false, false, 0)] - [BindColumn("AdsId", "广告ID", "int")] + [BindColumn("AdsId", "广告ID", "")] public Int32 AdsId { get { return _AdsId; } set { if (OnPropertyChanging(__.AdsId, value)) { _AdsId = value; OnPropertyChanged(__.AdsId); } } } #endregion @@ -312,7 +312,7 @@ namespace COMCMS.Core { switch (name) { - case __.Id : _Id = Convert.ToInt32(value); break; + case __.Id : _Id = value.ToInt(); break; case __.KindName : _KindName = Convert.ToString(value); break; case __.SubTitle : _SubTitle = Convert.ToString(value); break; case __.KindTitle : _KindTitle = Convert.ToString(value); break; @@ -323,26 +323,26 @@ namespace COMCMS.Core case __.TemplateFile : _TemplateFile = Convert.ToString(value); break; case __.DetailTemplateFile : _DetailTemplateFile = Convert.ToString(value); break; case __.KindDomain : _KindDomain = Convert.ToString(value); break; - case __.IsList : _IsList = Convert.ToInt32(value); break; - case __.PageSize : _PageSize = Convert.ToInt32(value); break; - case __.PId : _PId = Convert.ToInt32(value); break; - case __.Level : _Level = Convert.ToInt32(value); break; + case __.IsList : _IsList = value.ToInt(); break; + case __.PageSize : _PageSize = value.ToInt(); break; + case __.PId : _PId = value.ToInt(); break; + case __.Level : _Level = value.ToInt(); break; case __.Location : _Location = Convert.ToString(value); break; - case __.IsHide : _IsHide = Convert.ToInt32(value); break; - case __.IsLock : _IsLock = Convert.ToInt32(value); break; - case __.IsDel : _IsDel = Convert.ToInt32(value); break; - case __.IsComment : _IsComment = Convert.ToInt32(value); break; - case __.IsMember : _IsMember = Convert.ToInt32(value); break; - case __.IsShowSubDetail : _IsShowSubDetail = Convert.ToInt32(value); break; - case __.CatalogId : _CatalogId = Convert.ToInt32(value); break; - case __.Counts : _Counts = Convert.ToInt32(value); break; - case __.Rank : _Rank = Convert.ToInt32(value); break; + case __.IsHide : _IsHide = value.ToInt(); break; + case __.IsLock : _IsLock = value.ToInt(); break; + case __.IsDel : _IsDel = value.ToInt(); break; + case __.IsComment : _IsComment = value.ToInt(); break; + case __.IsMember : _IsMember = value.ToInt(); break; + case __.IsShowSubDetail : _IsShowSubDetail = value.ToInt(); break; + case __.CatalogId : _CatalogId = value.ToInt(); break; + case __.Counts : _Counts = value.ToInt(); break; + case __.Rank : _Rank = value.ToInt(); break; case __.Icon : _Icon = Convert.ToString(value); break; case __.ClassName : _ClassName = Convert.ToString(value); break; case __.BannerImg : _BannerImg = Convert.ToString(value); break; case __.KindInfo : _KindInfo = Convert.ToString(value); break; case __.Pic : _Pic = Convert.ToString(value); break; - case __.AdsId : _AdsId = Convert.ToInt32(value); break; + case __.AdsId : _AdsId = value.ToInt(); break; default: base[name] = value; break; } } diff --git a/COMCMS.Core/Mall/在线支付订单.cs b/COMCMS.Core/Mall/在线支付订单.cs index dcb609f..b2e9ac2 100644 --- a/COMCMS.Core/Mall/在线支付订单.cs +++ b/COMCMS.Core/Mall/在线支付订单.cs @@ -20,7 +20,7 @@ namespace COMCMS.Core [DisplayName("编号")] [Description("编号")] [DataObjectField(true, true, false, 0)] - [BindColumn("Id", "编号", "int", Master = true)] + [BindColumn("Id", "编号", "", Master = true)] public Int32 Id { get { return _Id; } set { if (OnPropertyChanging(__.Id, value)) { _Id = value; OnPropertyChanged(__.Id); } } } private String _PayOrderNum; @@ -28,7 +28,7 @@ namespace COMCMS.Core [DisplayName("在线支付订单号")] [Description("在线支付订单号,唯一")] [DataObjectField(false, false, true, 50)] - [BindColumn("PayOrderNum", "在线支付订单号,唯一", "nvarchar(50)")] + [BindColumn("PayOrderNum", "在线支付订单号,唯一", "")] public String PayOrderNum { get { return _PayOrderNum; } set { if (OnPropertyChanging(__.PayOrderNum, value)) { _PayOrderNum = value; OnPropertyChanged(__.PayOrderNum); } } } private Int32 _OrderId; @@ -36,7 +36,7 @@ namespace COMCMS.Core [DisplayName("订单ID")] [Description("订单ID")] [DataObjectField(false, false, false, 0)] - [BindColumn("OrderId", "订单ID", "int")] + [BindColumn("OrderId", "订单ID", "")] public Int32 OrderId { get { return _OrderId; } set { if (OnPropertyChanging(__.OrderId, value)) { _OrderId = value; OnPropertyChanged(__.OrderId); } } } private String _OrderNum; @@ -44,7 +44,7 @@ namespace COMCMS.Core [DisplayName("订单号")] [Description("订单号")] [DataObjectField(false, false, true, 50)] - [BindColumn("OrderNum", "订单号", "nvarchar(50)")] + [BindColumn("OrderNum", "订单号", "")] public String OrderNum { get { return _OrderNum; } set { if (OnPropertyChanging(__.OrderNum, value)) { _OrderNum = value; OnPropertyChanged(__.OrderNum); } } } private Int32 _PayId; @@ -52,7 +52,7 @@ namespace COMCMS.Core [DisplayName("支付方式ID")] [Description("支付方式ID")] [DataObjectField(false, false, false, 0)] - [BindColumn("PayId", "支付方式ID", "int")] + [BindColumn("PayId", "支付方式ID", "")] public Int32 PayId { get { return _PayId; } set { if (OnPropertyChanging(__.PayId, value)) { _PayId = value; OnPropertyChanged(__.PayId); } } } private String _PayType; @@ -60,7 +60,7 @@ namespace COMCMS.Core [DisplayName("付款方式")] [Description("付款方式")] [DataObjectField(false, false, true, 50)] - [BindColumn("PayType", "付款方式", "nvarchar(50)")] + [BindColumn("PayType", "付款方式", "")] public String PayType { get { return _PayType; } set { if (OnPropertyChanging(__.PayType, value)) { _PayType = value; OnPropertyChanged(__.PayType); } } } private String _PayTypeNotes; @@ -68,7 +68,7 @@ namespace COMCMS.Core [DisplayName("支付备注")] [Description("支付备注")] [DataObjectField(false, false, true, 250)] - [BindColumn("PayTypeNotes", "支付备注", "nvarchar(250)")] + [BindColumn("PayTypeNotes", "支付备注", "")] public String PayTypeNotes { get { return _PayTypeNotes; } set { if (OnPropertyChanging(__.PayTypeNotes, value)) { _PayTypeNotes = value; OnPropertyChanged(__.PayTypeNotes); } } } private String _Actions; @@ -76,7 +76,7 @@ namespace COMCMS.Core [DisplayName("日志记录")] [Description("日志记录")] [DataObjectField(false, false, true, 200)] - [BindColumn("Actions", "日志记录", "nvarchar(200)")] + [BindColumn("Actions", "日志记录", "")] public String Actions { get { return _Actions; } set { if (OnPropertyChanging(__.Actions, value)) { _Actions = value; OnPropertyChanged(__.Actions); } } } private Int32 _UId; @@ -84,7 +84,7 @@ namespace COMCMS.Core [DisplayName("用户ID")] [Description("用户ID")] [DataObjectField(false, false, false, 0)] - [BindColumn("UId", "用户ID", "int")] + [BindColumn("UId", "用户ID", "")] public Int32 UId { get { return _UId; } set { if (OnPropertyChanging(__.UId, value)) { _UId = value; OnPropertyChanged(__.UId); } } } private String _UserName; @@ -92,7 +92,7 @@ namespace COMCMS.Core [DisplayName("用户名")] [Description("用户名")] [DataObjectField(false, false, true, 50)] - [BindColumn("UserName", "用户名", "nvarchar(50)")] + [BindColumn("UserName", "用户名", "")] public String UserName { get { return _UserName; } set { if (OnPropertyChanging(__.UserName, value)) { _UserName = value; OnPropertyChanged(__.UserName); } } } private Int32 _TotalQty; @@ -100,7 +100,7 @@ namespace COMCMS.Core [DisplayName("总数量")] [Description("总数量")] [DataObjectField(false, false, false, 0)] - [BindColumn("TotalQty", "总数量", "int")] + [BindColumn("TotalQty", "总数量", "")] public Int32 TotalQty { get { return _TotalQty; } set { if (OnPropertyChanging(__.TotalQty, value)) { _TotalQty = value; OnPropertyChanged(__.TotalQty); } } } private Decimal _TotalPrice; @@ -108,7 +108,7 @@ namespace COMCMS.Core [DisplayName("总价格")] [Description("总价格")] [DataObjectField(false, false, false, 0)] - [BindColumn("TotalPrice", "总价格", "money")] + [BindColumn("TotalPrice", "总价格", "")] public Decimal TotalPrice { get { return _TotalPrice; } set { if (OnPropertyChanging(__.TotalPrice, value)) { _TotalPrice = value; OnPropertyChanged(__.TotalPrice); } } } private String _PaymentStatus; @@ -116,7 +116,7 @@ namespace COMCMS.Core [DisplayName("支付状态:未支付、已支付、已退款")] [Description("支付状态:未支付、已支付、已退款")] [DataObjectField(false, false, true, 50)] - [BindColumn("PaymentStatus", "支付状态:未支付、已支付、已退款", "nvarchar(50)")] + [BindColumn("PaymentStatus", "支付状态:未支付、已支付、已退款", "")] public String PaymentStatus { get { return _PaymentStatus; } set { if (OnPropertyChanging(__.PaymentStatus, value)) { _PaymentStatus = value; OnPropertyChanged(__.PaymentStatus); } } } private String _PaymentNotes; @@ -124,7 +124,7 @@ namespace COMCMS.Core [DisplayName("支付备注")] [Description("支付备注")] [DataObjectField(false, false, true, 250)] - [BindColumn("PaymentNotes", "支付备注", "nvarchar(250)")] + [BindColumn("PaymentNotes", "支付备注", "")] public String PaymentNotes { get { return _PaymentNotes; } set { if (OnPropertyChanging(__.PaymentNotes, value)) { _PaymentNotes = value; OnPropertyChanged(__.PaymentNotes); } } } private Int32 _IsOK; @@ -132,23 +132,23 @@ namespace COMCMS.Core [DisplayName("是否完成")] [Description("是否完成")] [DataObjectField(false, false, false, 0)] - [BindColumn("IsOK", "是否完成", "int")] + [BindColumn("IsOK", "是否完成", "")] public Int32 IsOK { get { return _IsOK; } set { if (OnPropertyChanging(__.IsOK, value)) { _IsOK = value; OnPropertyChanged(__.IsOK); } } } - private String _IP; + private String _Ip; /// 下单IP [DisplayName("下单IP")] [Description("下单IP")] [DataObjectField(false, false, true, 20)] - [BindColumn("IP", "下单IP", "nvarchar(20)")] - public String IP { get { return _IP; } set { if (OnPropertyChanging(__.IP, value)) { _IP = value; OnPropertyChanged(__.IP); } } } + [BindColumn("Ip", "下单IP", "")] + public String Ip { get { return _Ip; } set { if (OnPropertyChanging(__.Ip, value)) { _Ip = value; OnPropertyChanged(__.Ip); } } } private DateTime _AddTime; /// 添加时间 [DisplayName("添加时间")] [Description("添加时间")] [DataObjectField(false, false, true, 0)] - [BindColumn("AddTime", "添加时间", "datetime")] + [BindColumn("AddTime", "添加时间", "")] public DateTime AddTime { get { return _AddTime; } set { if (OnPropertyChanging(__.AddTime, value)) { _AddTime = value; OnPropertyChanged(__.AddTime); } } } private DateTime _ReceiveTime; @@ -156,7 +156,7 @@ namespace COMCMS.Core [DisplayName("回传时间")] [Description("回传时间")] [DataObjectField(false, false, true, 0)] - [BindColumn("ReceiveTime", "回传时间", "datetime")] + [BindColumn("ReceiveTime", "回传时间", "")] public DateTime ReceiveTime { get { return _ReceiveTime; } set { if (OnPropertyChanging(__.ReceiveTime, value)) { _ReceiveTime = value; OnPropertyChanged(__.ReceiveTime); } } } private Int32 _TypeId; @@ -164,7 +164,7 @@ namespace COMCMS.Core [DisplayName("支付的类型")] [Description("支付的类型")] [DataObjectField(false, false, false, 0)] - [BindColumn("TypeId", "支付的类型", "int")] + [BindColumn("TypeId", "支付的类型", "")] public Int32 TypeId { get { return _TypeId; } set { if (OnPropertyChanging(__.TypeId, value)) { _TypeId = value; OnPropertyChanged(__.TypeId); } } } private Int32 _MyType; @@ -172,7 +172,7 @@ namespace COMCMS.Core [DisplayName("系统类型")] [Description("系统类型")] [DataObjectField(false, false, false, 0)] - [BindColumn("MyType", "系统类型", "int")] + [BindColumn("MyType", "系统类型", "")] public Int32 MyType { get { return _MyType; } set { if (OnPropertyChanging(__.MyType, value)) { _MyType = value; OnPropertyChanged(__.MyType); } } } private String _Title; @@ -180,8 +180,16 @@ namespace COMCMS.Core [DisplayName("订单标题")] [Description("订单标题")] [DataObjectField(false, false, true, 50)] - [BindColumn("Title", "订单标题", "nvarchar(50)")] + [BindColumn("Title", "订单标题", "")] public String Title { get { return _Title; } set { if (OnPropertyChanging(__.Title, value)) { _Title = value; OnPropertyChanged(__.Title); } } } + + private String _OutTradeNo; + /// 支付成功流水号 + [DisplayName("支付成功流水号")] + [Description("支付成功流水号")] + [DataObjectField(false, false, true, 100)] + [BindColumn("OutTradeNo", "支付成功流水号", "")] + public String OutTradeNo { get { return _OutTradeNo; } set { if (OnPropertyChanging(__.OutTradeNo, value)) { _OutTradeNo = value; OnPropertyChanged(__.OutTradeNo); } } } #endregion #region 获取/设置 字段值 @@ -209,12 +217,13 @@ namespace COMCMS.Core case __.PaymentStatus : return _PaymentStatus; case __.PaymentNotes : return _PaymentNotes; case __.IsOK : return _IsOK; - case __.IP : return _IP; + case __.Ip : return _Ip; case __.AddTime : return _AddTime; case __.ReceiveTime : return _ReceiveTime; case __.TypeId : return _TypeId; case __.MyType : return _MyType; case __.Title : return _Title; + case __.OutTradeNo : return _OutTradeNo; default: return base[name]; } } @@ -222,27 +231,28 @@ namespace COMCMS.Core { switch (name) { - case __.Id : _Id = Convert.ToInt32(value); break; + case __.Id : _Id = value.ToInt(); break; case __.PayOrderNum : _PayOrderNum = Convert.ToString(value); break; - case __.OrderId : _OrderId = Convert.ToInt32(value); break; + case __.OrderId : _OrderId = value.ToInt(); break; case __.OrderNum : _OrderNum = Convert.ToString(value); break; - case __.PayId : _PayId = Convert.ToInt32(value); break; + case __.PayId : _PayId = value.ToInt(); break; case __.PayType : _PayType = Convert.ToString(value); break; case __.PayTypeNotes : _PayTypeNotes = Convert.ToString(value); break; case __.Actions : _Actions = Convert.ToString(value); break; - case __.UId : _UId = Convert.ToInt32(value); break; + case __.UId : _UId = value.ToInt(); break; case __.UserName : _UserName = Convert.ToString(value); break; - case __.TotalQty : _TotalQty = Convert.ToInt32(value); break; + case __.TotalQty : _TotalQty = value.ToInt(); break; case __.TotalPrice : _TotalPrice = Convert.ToDecimal(value); break; case __.PaymentStatus : _PaymentStatus = Convert.ToString(value); break; case __.PaymentNotes : _PaymentNotes = Convert.ToString(value); break; - case __.IsOK : _IsOK = Convert.ToInt32(value); break; - case __.IP : _IP = Convert.ToString(value); break; - case __.AddTime : _AddTime = Convert.ToDateTime(value); break; - case __.ReceiveTime : _ReceiveTime = Convert.ToDateTime(value); break; - case __.TypeId : _TypeId = Convert.ToInt32(value); break; - case __.MyType : _MyType = Convert.ToInt32(value); break; + case __.IsOK : _IsOK = value.ToInt(); break; + case __.Ip : _Ip = Convert.ToString(value); break; + case __.AddTime : _AddTime = value.ToDateTime(); break; + case __.ReceiveTime : _ReceiveTime = value.ToDateTime(); break; + case __.TypeId : _TypeId = value.ToInt(); break; + case __.MyType : _MyType = value.ToInt(); break; case __.Title : _Title = Convert.ToString(value); break; + case __.OutTradeNo : _OutTradeNo = Convert.ToString(value); break; default: base[name] = value; break; } } @@ -299,7 +309,7 @@ namespace COMCMS.Core public static readonly Field IsOK = FindByName(__.IsOK); /// 下单IP - public static readonly Field IP = FindByName(__.IP); + public static readonly Field Ip = FindByName(__.Ip); /// 添加时间 public static readonly Field AddTime = FindByName(__.AddTime); @@ -316,6 +326,9 @@ namespace COMCMS.Core /// 订单标题 public static readonly Field Title = FindByName(__.Title); + /// 支付成功流水号 + public static readonly Field OutTradeNo = FindByName(__.OutTradeNo); + static Field FindByName(String name) { return Meta.Table.FindByName(name); } } @@ -368,7 +381,7 @@ namespace COMCMS.Core public const String IsOK = "IsOK"; /// 下单IP - public const String IP = "IP"; + public const String Ip = "Ip"; /// 添加时间 public const String AddTime = "AddTime"; @@ -384,6 +397,9 @@ namespace COMCMS.Core /// 订单标题 public const String Title = "Title"; + + /// 支付成功流水号 + public const String OutTradeNo = "OutTradeNo"; } #endregion } @@ -438,7 +454,7 @@ namespace COMCMS.Core Int32 IsOK { get; set; } /// 下单IP - String IP { get; set; } + String Ip { get; set; } /// 添加时间 DateTime AddTime { get; set; } @@ -454,6 +470,9 @@ namespace COMCMS.Core /// 订单标题 String Title { get; set; } + + /// 支付成功流水号 + String OutTradeNo { get; set; } #endregion #region 获取/设置 字段值 diff --git a/COMCMS.Core/Mall/订单.cs b/COMCMS.Core/Mall/订单.cs index a1d5277..652000c 100644 --- a/COMCMS.Core/Mall/订单.cs +++ b/COMCMS.Core/Mall/订单.cs @@ -20,7 +20,7 @@ namespace COMCMS.Core [DisplayName("编号")] [Description("编号")] [DataObjectField(true, true, false, 0)] - [BindColumn("Id", "编号", "int", Master = true)] + [BindColumn("Id", "编号", "", Master = true)] public Int32 Id { get { return _Id; } set { if (OnPropertyChanging(__.Id, value)) { _Id = value; OnPropertyChanged(__.Id); } } } private String _OrderNum; @@ -28,7 +28,7 @@ namespace COMCMS.Core [DisplayName("订单号")] [Description("订单号")] [DataObjectField(false, false, true, 50)] - [BindColumn("OrderNum", "订单号", "nvarchar(50)")] + [BindColumn("OrderNum", "订单号", "")] public String OrderNum { get { return _OrderNum; } set { if (OnPropertyChanging(__.OrderNum, value)) { _OrderNum = value; OnPropertyChanged(__.OrderNum); } } } private Int32 _UId; @@ -36,7 +36,7 @@ namespace COMCMS.Core [DisplayName("用户ID")] [Description("用户ID")] [DataObjectField(false, false, false, 0)] - [BindColumn("UId", "用户ID", "int")] + [BindColumn("UId", "用户ID", "")] public Int32 UId { get { return _UId; } set { if (OnPropertyChanging(__.UId, value)) { _UId = value; OnPropertyChanged(__.UId); } } } private String _UserName; @@ -44,7 +44,7 @@ namespace COMCMS.Core [DisplayName("下单用户名")] [Description("下单用户名")] [DataObjectField(false, false, true, 50)] - [BindColumn("UserName", "下单用户名", "nvarchar(50)")] + [BindColumn("UserName", "下单用户名", "")] public String UserName { get { return _UserName; } set { if (OnPropertyChanging(__.UserName, value)) { _UserName = value; OnPropertyChanged(__.UserName); } } } private Int32 _ShopId; @@ -52,7 +52,7 @@ namespace COMCMS.Core [DisplayName("商户ID")] [Description("商户ID")] [DataObjectField(false, false, false, 0)] - [BindColumn("ShopId", "商户ID", "int")] + [BindColumn("ShopId", "商户ID", "")] public Int32 ShopId { get { return _ShopId; } set { if (OnPropertyChanging(__.ShopId, value)) { _ShopId = value; OnPropertyChanged(__.ShopId); } } } private Int32 _Credit; @@ -60,7 +60,7 @@ namespace COMCMS.Core [DisplayName("积分")] [Description("积分")] [DataObjectField(false, false, false, 0)] - [BindColumn("Credit", "积分", "int")] + [BindColumn("Credit", "积分", "")] public Int32 Credit { get { return _Credit; } set { if (OnPropertyChanging(__.Credit, value)) { _Credit = value; OnPropertyChanged(__.Credit); } } } private Int32 _TotalQty; @@ -68,7 +68,7 @@ namespace COMCMS.Core [DisplayName("总数量")] [Description("总数量")] [DataObjectField(false, false, false, 0)] - [BindColumn("TotalQty", "总数量", "int")] + [BindColumn("TotalQty", "总数量", "")] public Int32 TotalQty { get { return _TotalQty; } set { if (OnPropertyChanging(__.TotalQty, value)) { _TotalQty = value; OnPropertyChanged(__.TotalQty); } } } private Decimal _TotalPrice; @@ -76,7 +76,7 @@ namespace COMCMS.Core [DisplayName("总价格")] [Description("总价格")] [DataObjectField(false, false, false, 0)] - [BindColumn("TotalPrice", "总价格", "money")] + [BindColumn("TotalPrice", "总价格", "")] public Decimal TotalPrice { get { return _TotalPrice; } set { if (OnPropertyChanging(__.TotalPrice, value)) { _TotalPrice = value; OnPropertyChanged(__.TotalPrice); } } } private Decimal _Discount; @@ -84,7 +84,7 @@ namespace COMCMS.Core [DisplayName("折扣")] [Description("折扣")] [DataObjectField(false, false, false, 0)] - [BindColumn("Discount", "折扣", "money")] + [BindColumn("Discount", "折扣", "")] public Decimal Discount { get { return _Discount; } set { if (OnPropertyChanging(__.Discount, value)) { _Discount = value; OnPropertyChanged(__.Discount); } } } private Decimal _Fare; @@ -92,7 +92,7 @@ namespace COMCMS.Core [DisplayName("运费")] [Description("运费")] [DataObjectField(false, false, false, 0)] - [BindColumn("Fare", "运费", "money")] + [BindColumn("Fare", "运费", "")] public Decimal Fare { get { return _Fare; } set { if (OnPropertyChanging(__.Fare, value)) { _Fare = value; OnPropertyChanged(__.Fare); } } } private Decimal _TotalTax; @@ -100,7 +100,7 @@ namespace COMCMS.Core [DisplayName("税")] [Description("税")] [DataObjectField(false, false, false, 0)] - [BindColumn("TotalTax", "税", "money")] + [BindColumn("TotalTax", "税", "")] public Decimal TotalTax { get { return _TotalTax; } set { if (OnPropertyChanging(__.TotalTax, value)) { _TotalTax = value; OnPropertyChanged(__.TotalTax); } } } private Decimal _TotalPay; @@ -108,7 +108,7 @@ namespace COMCMS.Core [DisplayName("总支付价格")] [Description("总支付价格")] [DataObjectField(false, false, false, 0)] - [BindColumn("TotalPay", "总支付价格", "money")] + [BindColumn("TotalPay", "总支付价格", "")] public Decimal TotalPay { get { return _TotalPay; } set { if (OnPropertyChanging(__.TotalPay, value)) { _TotalPay = value; OnPropertyChanged(__.TotalPay); } } } private Int32 _BackCredits; @@ -116,7 +116,7 @@ namespace COMCMS.Core [DisplayName("返现积分")] [Description("返现积分")] [DataObjectField(false, false, false, 0)] - [BindColumn("BackCredits", "返现积分", "int")] + [BindColumn("BackCredits", "返现积分", "")] public Int32 BackCredits { get { return _BackCredits; } set { if (OnPropertyChanging(__.BackCredits, value)) { _BackCredits = value; OnPropertyChanged(__.BackCredits); } } } private String _RealName; @@ -124,7 +124,7 @@ namespace COMCMS.Core [DisplayName("姓名")] [Description("姓名")] [DataObjectField(false, false, true, 50)] - [BindColumn("RealName", "姓名", "nvarchar(50)")] + [BindColumn("RealName", "姓名", "")] public String RealName { get { return _RealName; } set { if (OnPropertyChanging(__.RealName, value)) { _RealName = value; OnPropertyChanged(__.RealName); } } } private String _Country; @@ -132,7 +132,7 @@ namespace COMCMS.Core [DisplayName("国家")] [Description("国家")] [DataObjectField(false, false, true, 50)] - [BindColumn("Country", "国家", "nvarchar(50)")] + [BindColumn("Country", "国家", "")] public String Country { get { return _Country; } set { if (OnPropertyChanging(__.Country, value)) { _Country = value; OnPropertyChanged(__.Country); } } } private String _Province; @@ -140,7 +140,7 @@ namespace COMCMS.Core [DisplayName("省份")] [Description("省份")] [DataObjectField(false, false, true, 50)] - [BindColumn("Province", "省份", "nvarchar(50)")] + [BindColumn("Province", "省份", "")] public String Province { get { return _Province; } set { if (OnPropertyChanging(__.Province, value)) { _Province = value; OnPropertyChanged(__.Province); } } } private String _City; @@ -148,7 +148,7 @@ namespace COMCMS.Core [DisplayName("城市")] [Description("城市")] [DataObjectField(false, false, true, 50)] - [BindColumn("City", "城市", "nvarchar(50)")] + [BindColumn("City", "城市", "")] public String City { get { return _City; } set { if (OnPropertyChanging(__.City, value)) { _City = value; OnPropertyChanged(__.City); } } } private String _District; @@ -156,7 +156,7 @@ namespace COMCMS.Core [DisplayName("区")] [Description("区")] [DataObjectField(false, false, true, 50)] - [BindColumn("District", "区", "nvarchar(50)")] + [BindColumn("District", "区", "")] public String District { get { return _District; } set { if (OnPropertyChanging(__.District, value)) { _District = value; OnPropertyChanged(__.District); } } } private String _Address; @@ -164,7 +164,7 @@ namespace COMCMS.Core [DisplayName("详细地址")] [Description("详细地址")] [DataObjectField(false, false, true, 250)] - [BindColumn("Address", "详细地址", "nvarchar(250)")] + [BindColumn("Address", "详细地址", "")] public String Address { get { return _Address; } set { if (OnPropertyChanging(__.Address, value)) { _Address = value; OnPropertyChanged(__.Address); } } } private String _PostCode; @@ -172,7 +172,7 @@ namespace COMCMS.Core [DisplayName("邮编")] [Description("邮编")] [DataObjectField(false, false, true, 20)] - [BindColumn("PostCode", "邮编", "nvarchar(20)")] + [BindColumn("PostCode", "邮编", "")] public String PostCode { get { return _PostCode; } set { if (OnPropertyChanging(__.PostCode, value)) { _PostCode = value; OnPropertyChanged(__.PostCode); } } } private String _Tel; @@ -180,7 +180,7 @@ namespace COMCMS.Core [DisplayName("手机")] [Description("手机")] [DataObjectField(false, false, true, 20)] - [BindColumn("Tel", "手机", "nvarchar(20)")] + [BindColumn("Tel", "手机", "")] public String Tel { get { return _Tel; } set { if (OnPropertyChanging(__.Tel, value)) { _Tel = value; OnPropertyChanged(__.Tel); } } } private String _Mobile; @@ -188,7 +188,7 @@ namespace COMCMS.Core [DisplayName("手机")] [Description("手机")] [DataObjectField(false, false, true, 20)] - [BindColumn("Mobile", "手机", "nvarchar(20)")] + [BindColumn("Mobile", "手机", "")] public String Mobile { get { return _Mobile; } set { if (OnPropertyChanging(__.Mobile, value)) { _Mobile = value; OnPropertyChanged(__.Mobile); } } } private String _Email; @@ -196,7 +196,7 @@ namespace COMCMS.Core [DisplayName("邮箱")] [Description("邮箱")] [DataObjectField(false, false, true, 100)] - [BindColumn("Email", "邮箱", "nvarchar(100)")] + [BindColumn("Email", "邮箱", "")] public String Email { get { return _Email; } set { if (OnPropertyChanging(__.Email, value)) { _Email = value; OnPropertyChanged(__.Email); } } } private String _Notes; @@ -204,7 +204,7 @@ namespace COMCMS.Core [DisplayName("备注")] [Description("备注")] [DataObjectField(false, false, true, 250)] - [BindColumn("Notes", "备注", "nvarchar(250)")] + [BindColumn("Notes", "备注", "")] public String Notes { get { return _Notes; } set { if (OnPropertyChanging(__.Notes, value)) { _Notes = value; OnPropertyChanged(__.Notes); } } } private String _AdminNotes; @@ -212,7 +212,7 @@ namespace COMCMS.Core [DisplayName("管理员备注")] [Description("管理员备注")] [DataObjectField(false, false, true, 250)] - [BindColumn("AdminNotes", "管理员备注", "nvarchar(250)")] + [BindColumn("AdminNotes", "管理员备注", "")] public String AdminNotes { get { return _AdminNotes; } set { if (OnPropertyChanging(__.AdminNotes, value)) { _AdminNotes = value; OnPropertyChanged(__.AdminNotes); } } } private String _Pic; @@ -220,7 +220,7 @@ namespace COMCMS.Core [DisplayName("图片")] [Description("图片")] [DataObjectField(false, false, true, -1)] - [BindColumn("Pic", "图片", "ntext")] + [BindColumn("Pic", "图片", "")] public String Pic { get { return _Pic; } set { if (OnPropertyChanging(__.Pic, value)) { _Pic = value; OnPropertyChanged(__.Pic); } } } private Int32 _DeliverId; @@ -228,7 +228,7 @@ namespace COMCMS.Core [DisplayName("配送方式ID")] [Description("配送方式ID")] [DataObjectField(false, false, false, 0)] - [BindColumn("DeliverId", "配送方式ID", "int")] + [BindColumn("DeliverId", "配送方式ID", "")] public Int32 DeliverId { get { return _DeliverId; } set { if (OnPropertyChanging(__.DeliverId, value)) { _DeliverId = value; OnPropertyChanged(__.DeliverId); } } } private String _DeliverType; @@ -236,7 +236,7 @@ namespace COMCMS.Core [DisplayName("配送方式名称")] [Description("配送方式名称")] [DataObjectField(false, false, true, 50)] - [BindColumn("DeliverType", "配送方式名称", "nvarchar(50)")] + [BindColumn("DeliverType", "配送方式名称", "")] public String DeliverType { get { return _DeliverType; } set { if (OnPropertyChanging(__.DeliverType, value)) { _DeliverType = value; OnPropertyChanged(__.DeliverType); } } } private String _DeliverNO; @@ -244,7 +244,7 @@ namespace COMCMS.Core [DisplayName("运单号")] [Description("运单号")] [DataObjectField(false, false, true, 50)] - [BindColumn("DeliverNO", "运单号", "nvarchar(50)")] + [BindColumn("DeliverNO", "运单号", "")] public String DeliverNO { get { return _DeliverNO; } set { if (OnPropertyChanging(__.DeliverNO, value)) { _DeliverNO = value; OnPropertyChanged(__.DeliverNO); } } } private String _DeliverNotes; @@ -252,7 +252,7 @@ namespace COMCMS.Core [DisplayName("配送备注")] [Description("配送备注")] [DataObjectField(false, false, true, 250)] - [BindColumn("DeliverNotes", "配送备注", "nvarchar(250)")] + [BindColumn("DeliverNotes", "配送备注", "")] public String DeliverNotes { get { return _DeliverNotes; } set { if (OnPropertyChanging(__.DeliverNotes, value)) { _DeliverNotes = value; OnPropertyChanged(__.DeliverNotes); } } } private Int32 _PayId; @@ -260,7 +260,7 @@ namespace COMCMS.Core [DisplayName("支付方式ID")] [Description("支付方式ID")] [DataObjectField(false, false, false, 0)] - [BindColumn("PayId", "支付方式ID", "int")] + [BindColumn("PayId", "支付方式ID", "")] public Int32 PayId { get { return _PayId; } set { if (OnPropertyChanging(__.PayId, value)) { _PayId = value; OnPropertyChanged(__.PayId); } } } private String _PayType; @@ -268,7 +268,7 @@ namespace COMCMS.Core [DisplayName("付款方式")] [Description("付款方式")] [DataObjectField(false, false, true, 50)] - [BindColumn("PayType", "付款方式", "nvarchar(50)")] + [BindColumn("PayType", "付款方式", "")] public String PayType { get { return _PayType; } set { if (OnPropertyChanging(__.PayType, value)) { _PayType = value; OnPropertyChanged(__.PayType); } } } private String _PayTypeNotes; @@ -276,7 +276,7 @@ namespace COMCMS.Core [DisplayName("支付备注")] [Description("支付备注")] [DataObjectField(false, false, true, 250)] - [BindColumn("PayTypeNotes", "支付备注", "nvarchar(250)")] + [BindColumn("PayTypeNotes", "支付备注", "")] public String PayTypeNotes { get { return _PayTypeNotes; } set { if (OnPropertyChanging(__.PayTypeNotes, value)) { _PayTypeNotes = value; OnPropertyChanged(__.PayTypeNotes); } } } private String _OrderStatus; @@ -284,7 +284,7 @@ namespace COMCMS.Core [DisplayName("订单状态:未确认、已确认、已完成、已取消")] [Description("订单状态:未确认、已确认、已完成、已取消")] [DataObjectField(false, false, true, 50)] - [BindColumn("OrderStatus", "订单状态:未确认、已确认、已完成、已取消", "nvarchar(50)")] + [BindColumn("OrderStatus", "订单状态:未确认、已确认、已完成、已取消", "")] public String OrderStatus { get { return _OrderStatus; } set { if (OnPropertyChanging(__.OrderStatus, value)) { _OrderStatus = value; OnPropertyChanged(__.OrderStatus); } } } private String _PaymentStatus; @@ -292,7 +292,7 @@ namespace COMCMS.Core [DisplayName("支付状态:未支付、已支付、已退款")] [Description("支付状态:未支付、已支付、已退款")] [DataObjectField(false, false, true, 50)] - [BindColumn("PaymentStatus", "支付状态:未支付、已支付、已退款", "nvarchar(50)")] + [BindColumn("PaymentStatus", "支付状态:未支付、已支付、已退款", "")] public String PaymentStatus { get { return _PaymentStatus; } set { if (OnPropertyChanging(__.PaymentStatus, value)) { _PaymentStatus = value; OnPropertyChanged(__.PaymentStatus); } } } private String _DeliverStatus; @@ -300,7 +300,7 @@ namespace COMCMS.Core [DisplayName("配送状态:未配送、配货中、已配送、已收到、退货中、已退货")] [Description("配送状态:未配送、配货中、已配送、已收到、退货中、已退货")] [DataObjectField(false, false, true, 50)] - [BindColumn("DeliverStatus", "配送状态:未配送、配货中、已配送、已收到、退货中、已退货", "nvarchar(50)")] + [BindColumn("DeliverStatus", "配送状态:未配送、配货中、已配送、已收到、退货中、已退货", "")] public String DeliverStatus { get { return _DeliverStatus; } set { if (OnPropertyChanging(__.DeliverStatus, value)) { _DeliverStatus = value; OnPropertyChanged(__.DeliverStatus); } } } private DateTime _AddTime; @@ -308,23 +308,23 @@ namespace COMCMS.Core [DisplayName("添加时间")] [Description("添加时间")] [DataObjectField(false, false, true, 0)] - [BindColumn("AddTime", "添加时间", "datetime")] + [BindColumn("AddTime", "添加时间", "")] public DateTime AddTime { get { return _AddTime; } set { if (OnPropertyChanging(__.AddTime, value)) { _AddTime = value; OnPropertyChanged(__.AddTime); } } } - private String _IP; + private String _Ip; /// 下单IP [DisplayName("下单IP")] [Description("下单IP")] [DataObjectField(false, false, true, 20)] - [BindColumn("IP", "下单IP", "nvarchar(20)")] - public String IP { get { return _IP; } set { if (OnPropertyChanging(__.IP, value)) { _IP = value; OnPropertyChanged(__.IP); } } } + [BindColumn("Ip", "下单IP", "")] + public String Ip { get { return _Ip; } set { if (OnPropertyChanging(__.Ip, value)) { _Ip = value; OnPropertyChanged(__.Ip); } } } private Int32 _IsInvoice; /// 是否需要发票 [DisplayName("是否需要发票")] [Description("是否需要发票")] [DataObjectField(false, false, false, 0)] - [BindColumn("IsInvoice", "是否需要发票", "int")] + [BindColumn("IsInvoice", "是否需要发票", "")] public Int32 IsInvoice { get { return _IsInvoice; } set { if (OnPropertyChanging(__.IsInvoice, value)) { _IsInvoice = value; OnPropertyChanged(__.IsInvoice); } } } private String _InvoiceCompanyName; @@ -332,7 +332,7 @@ namespace COMCMS.Core [DisplayName("抬头")] [Description("抬头")] [DataObjectField(false, false, true, 50)] - [BindColumn("InvoiceCompanyName", "抬头", "nvarchar(50)")] + [BindColumn("InvoiceCompanyName", "抬头", "")] public String InvoiceCompanyName { get { return _InvoiceCompanyName; } set { if (OnPropertyChanging(__.InvoiceCompanyName, value)) { _InvoiceCompanyName = value; OnPropertyChanged(__.InvoiceCompanyName); } } } private String _InvoiceCompanyID; @@ -340,7 +340,7 @@ namespace COMCMS.Core [DisplayName("纳税人识别号")] [Description("纳税人识别号")] [DataObjectField(false, false, true, 100)] - [BindColumn("InvoiceCompanyID", "纳税人识别号", "nvarchar(100)")] + [BindColumn("InvoiceCompanyID", "纳税人识别号", "")] public String InvoiceCompanyID { get { return _InvoiceCompanyID; } set { if (OnPropertyChanging(__.InvoiceCompanyID, value)) { _InvoiceCompanyID = value; OnPropertyChanged(__.InvoiceCompanyID); } } } private String _InvoiceType; @@ -348,7 +348,7 @@ namespace COMCMS.Core [DisplayName("发票内容")] [Description("发票内容")] [DataObjectField(false, false, true, 50)] - [BindColumn("InvoiceType", "发票内容", "nvarchar(50)")] + [BindColumn("InvoiceType", "发票内容", "")] public String InvoiceType { get { return _InvoiceType; } set { if (OnPropertyChanging(__.InvoiceType, value)) { _InvoiceType = value; OnPropertyChanged(__.InvoiceType); } } } private String _InvoiceNote; @@ -356,7 +356,7 @@ namespace COMCMS.Core [DisplayName("发票备注")] [Description("发票备注")] [DataObjectField(false, false, true, 250)] - [BindColumn("InvoiceNote", "发票备注", "nvarchar(250)")] + [BindColumn("InvoiceNote", "发票备注", "")] public String InvoiceNote { get { return _InvoiceNote; } set { if (OnPropertyChanging(__.InvoiceNote, value)) { _InvoiceNote = value; OnPropertyChanged(__.InvoiceNote); } } } private Int32 _IsRead; @@ -364,7 +364,7 @@ namespace COMCMS.Core [DisplayName("是否未读")] [Description("是否未读")] [DataObjectField(false, false, false, 0)] - [BindColumn("IsRead", "是否未读", "int")] + [BindColumn("IsRead", "是否未读", "")] public Int32 IsRead { get { return _IsRead; } set { if (OnPropertyChanging(__.IsRead, value)) { _IsRead = value; OnPropertyChanged(__.IsRead); } } } private Int32 _IsEnd; @@ -372,7 +372,7 @@ namespace COMCMS.Core [DisplayName("是否结束")] [Description("是否结束")] [DataObjectField(false, false, false, 0)] - [BindColumn("IsEnd", "是否结束", "int")] + [BindColumn("IsEnd", "是否结束", "")] public Int32 IsEnd { get { return _IsEnd; } set { if (OnPropertyChanging(__.IsEnd, value)) { _IsEnd = value; OnPropertyChanged(__.IsEnd); } } } private DateTime _EndTime; @@ -380,7 +380,7 @@ namespace COMCMS.Core [DisplayName("结束时间")] [Description("结束时间")] [DataObjectField(false, false, true, 0)] - [BindColumn("EndTime", "结束时间", "datetime")] + [BindColumn("EndTime", "结束时间", "")] public DateTime EndTime { get { return _EndTime; } set { if (OnPropertyChanging(__.EndTime, value)) { _EndTime = value; OnPropertyChanged(__.EndTime); } } } private Int32 _IsOk; @@ -388,7 +388,7 @@ namespace COMCMS.Core [DisplayName("订单是否顺利完成")] [Description("订单是否顺利完成")] [DataObjectField(false, false, false, 0)] - [BindColumn("IsOk", "订单是否顺利完成", "int")] + [BindColumn("IsOk", "订单是否顺利完成", "")] public Int32 IsOk { get { return _IsOk; } set { if (OnPropertyChanging(__.IsOk, value)) { _IsOk = value; OnPropertyChanged(__.IsOk); } } } private Int32 _IsComment; @@ -396,7 +396,7 @@ namespace COMCMS.Core [DisplayName("订单已经评论")] [Description("订单已经评论")] [DataObjectField(false, false, false, 0)] - [BindColumn("IsComment", "订单已经评论", "int")] + [BindColumn("IsComment", "订单已经评论", "")] public Int32 IsComment { get { return _IsComment; } set { if (OnPropertyChanging(__.IsComment, value)) { _IsComment = value; OnPropertyChanged(__.IsComment); } } } private String _Flag1; @@ -404,7 +404,7 @@ namespace COMCMS.Core [DisplayName("预留字段1")] [Description("预留字段1")] [DataObjectField(false, false, true, 200)] - [BindColumn("Flag1", "预留字段1", "nvarchar(200)")] + [BindColumn("Flag1", "预留字段1", "")] public String Flag1 { get { return _Flag1; } set { if (OnPropertyChanging(__.Flag1, value)) { _Flag1 = value; OnPropertyChanged(__.Flag1); } } } private String _Flag2; @@ -412,7 +412,7 @@ namespace COMCMS.Core [DisplayName("预留字段2")] [Description("预留字段2")] [DataObjectField(false, false, true, 200)] - [BindColumn("Flag2", "预留字段2", "nvarchar(200)")] + [BindColumn("Flag2", "预留字段2", "")] public String Flag2 { get { return _Flag2; } set { if (OnPropertyChanging(__.Flag2, value)) { _Flag2 = value; OnPropertyChanged(__.Flag2); } } } private String _Flag3; @@ -420,7 +420,7 @@ namespace COMCMS.Core [DisplayName("预留字段3")] [Description("预留字段3")] [DataObjectField(false, false, true, 200)] - [BindColumn("Flag3", "预留字段3", "nvarchar(200)")] + [BindColumn("Flag3", "预留字段3", "")] public String Flag3 { get { return _Flag3; } set { if (OnPropertyChanging(__.Flag3, value)) { _Flag3 = value; OnPropertyChanged(__.Flag3); } } } private String _Title; @@ -428,7 +428,7 @@ namespace COMCMS.Core [DisplayName("订单名称")] [Description("订单名称")] [DataObjectField(false, false, true, 200)] - [BindColumn("Title", "订单名称", "nvarchar(200)")] + [BindColumn("Title", "订单名称", "")] public String Title { get { return _Title; } set { if (OnPropertyChanging(__.Title, value)) { _Title = value; OnPropertyChanged(__.Title); } } } private DateTime _LastModTime; @@ -436,7 +436,7 @@ namespace COMCMS.Core [DisplayName("最后操作时间")] [Description("最后操作时间")] [DataObjectField(false, false, true, 0)] - [BindColumn("LastModTime", "最后操作时间", "datetime")] + [BindColumn("LastModTime", "最后操作时间", "")] public DateTime LastModTime { get { return _LastModTime; } set { if (OnPropertyChanging(__.LastModTime, value)) { _LastModTime = value; OnPropertyChanged(__.LastModTime); } } } private Int32 _OrderType; @@ -444,7 +444,7 @@ namespace COMCMS.Core [DisplayName("订单类型")] [Description("订单类型,0为商品订单")] [DataObjectField(false, false, false, 0)] - [BindColumn("OrderType", "订单类型,0为商品订单", "int")] + [BindColumn("OrderType", "订单类型,0为商品订单", "")] public Int32 OrderType { get { return _OrderType; } set { if (OnPropertyChanging(__.OrderType, value)) { _OrderType = value; OnPropertyChanged(__.OrderType); } } } private Int32 _MyType; @@ -452,8 +452,16 @@ namespace COMCMS.Core [DisplayName("系统类型")] [Description("系统类型")] [DataObjectField(false, false, false, 0)] - [BindColumn("MyType", "系统类型", "int")] + [BindColumn("MyType", "系统类型", "")] public Int32 MyType { get { return _MyType; } set { if (OnPropertyChanging(__.MyType, value)) { _MyType = value; OnPropertyChanged(__.MyType); } } } + + private String _OutTradeNo; + /// 支付成功流水号 + [DisplayName("支付成功流水号")] + [Description("支付成功流水号")] + [DataObjectField(false, false, true, 100)] + [BindColumn("OutTradeNo", "支付成功流水号", "")] + public String OutTradeNo { get { return _OutTradeNo; } set { if (OnPropertyChanging(__.OutTradeNo, value)) { _OutTradeNo = value; OnPropertyChanged(__.OutTradeNo); } } } #endregion #region 获取/设置 字段值 @@ -503,7 +511,7 @@ namespace COMCMS.Core case __.PaymentStatus : return _PaymentStatus; case __.DeliverStatus : return _DeliverStatus; case __.AddTime : return _AddTime; - case __.IP : return _IP; + case __.Ip : return _Ip; case __.IsInvoice : return _IsInvoice; case __.InvoiceCompanyName : return _InvoiceCompanyName; case __.InvoiceCompanyID : return _InvoiceCompanyID; @@ -521,6 +529,7 @@ namespace COMCMS.Core case __.LastModTime : return _LastModTime; case __.OrderType : return _OrderType; case __.MyType : return _MyType; + case __.OutTradeNo : return _OutTradeNo; default: return base[name]; } } @@ -528,19 +537,19 @@ namespace COMCMS.Core { switch (name) { - case __.Id : _Id = Convert.ToInt32(value); break; + case __.Id : _Id = value.ToInt(); break; case __.OrderNum : _OrderNum = Convert.ToString(value); break; - case __.UId : _UId = Convert.ToInt32(value); break; + case __.UId : _UId = value.ToInt(); break; case __.UserName : _UserName = Convert.ToString(value); break; - case __.ShopId : _ShopId = Convert.ToInt32(value); break; - case __.Credit : _Credit = Convert.ToInt32(value); break; - case __.TotalQty : _TotalQty = Convert.ToInt32(value); break; + case __.ShopId : _ShopId = value.ToInt(); break; + case __.Credit : _Credit = value.ToInt(); break; + case __.TotalQty : _TotalQty = value.ToInt(); break; case __.TotalPrice : _TotalPrice = Convert.ToDecimal(value); break; case __.Discount : _Discount = Convert.ToDecimal(value); break; case __.Fare : _Fare = Convert.ToDecimal(value); break; case __.TotalTax : _TotalTax = Convert.ToDecimal(value); break; case __.TotalPay : _TotalPay = Convert.ToDecimal(value); break; - case __.BackCredits : _BackCredits = Convert.ToInt32(value); break; + case __.BackCredits : _BackCredits = value.ToInt(); break; case __.RealName : _RealName = Convert.ToString(value); break; case __.Country : _Country = Convert.ToString(value); break; case __.Province : _Province = Convert.ToString(value); break; @@ -554,35 +563,36 @@ namespace COMCMS.Core case __.Notes : _Notes = Convert.ToString(value); break; case __.AdminNotes : _AdminNotes = Convert.ToString(value); break; case __.Pic : _Pic = Convert.ToString(value); break; - case __.DeliverId : _DeliverId = Convert.ToInt32(value); break; + case __.DeliverId : _DeliverId = value.ToInt(); break; case __.DeliverType : _DeliverType = Convert.ToString(value); break; case __.DeliverNO : _DeliverNO = Convert.ToString(value); break; case __.DeliverNotes : _DeliverNotes = Convert.ToString(value); break; - case __.PayId : _PayId = Convert.ToInt32(value); break; + case __.PayId : _PayId = value.ToInt(); break; case __.PayType : _PayType = Convert.ToString(value); break; case __.PayTypeNotes : _PayTypeNotes = Convert.ToString(value); break; case __.OrderStatus : _OrderStatus = Convert.ToString(value); break; case __.PaymentStatus : _PaymentStatus = Convert.ToString(value); break; case __.DeliverStatus : _DeliverStatus = Convert.ToString(value); break; - case __.AddTime : _AddTime = Convert.ToDateTime(value); break; - case __.IP : _IP = Convert.ToString(value); break; - case __.IsInvoice : _IsInvoice = Convert.ToInt32(value); break; + case __.AddTime : _AddTime = value.ToDateTime(); break; + case __.Ip : _Ip = Convert.ToString(value); break; + case __.IsInvoice : _IsInvoice = value.ToInt(); break; case __.InvoiceCompanyName : _InvoiceCompanyName = Convert.ToString(value); break; case __.InvoiceCompanyID : _InvoiceCompanyID = Convert.ToString(value); break; case __.InvoiceType : _InvoiceType = Convert.ToString(value); break; case __.InvoiceNote : _InvoiceNote = Convert.ToString(value); break; - case __.IsRead : _IsRead = Convert.ToInt32(value); break; - case __.IsEnd : _IsEnd = Convert.ToInt32(value); break; - case __.EndTime : _EndTime = Convert.ToDateTime(value); break; - case __.IsOk : _IsOk = Convert.ToInt32(value); break; - case __.IsComment : _IsComment = Convert.ToInt32(value); break; + case __.IsRead : _IsRead = value.ToInt(); break; + case __.IsEnd : _IsEnd = value.ToInt(); break; + case __.EndTime : _EndTime = value.ToDateTime(); break; + case __.IsOk : _IsOk = value.ToInt(); break; + case __.IsComment : _IsComment = value.ToInt(); break; case __.Flag1 : _Flag1 = Convert.ToString(value); break; case __.Flag2 : _Flag2 = Convert.ToString(value); break; case __.Flag3 : _Flag3 = Convert.ToString(value); break; case __.Title : _Title = Convert.ToString(value); break; - case __.LastModTime : _LastModTime = Convert.ToDateTime(value); break; - case __.OrderType : _OrderType = Convert.ToInt32(value); break; - case __.MyType : _MyType = Convert.ToInt32(value); break; + case __.LastModTime : _LastModTime = value.ToDateTime(); break; + case __.OrderType : _OrderType = value.ToInt(); break; + case __.MyType : _MyType = value.ToInt(); break; + case __.OutTradeNo : _OutTradeNo = Convert.ToString(value); break; default: base[name] = value; break; } } @@ -705,7 +715,7 @@ namespace COMCMS.Core public static readonly Field AddTime = FindByName(__.AddTime); /// 下单IP - public static readonly Field IP = FindByName(__.IP); + public static readonly Field Ip = FindByName(__.Ip); /// 是否需要发票 public static readonly Field IsInvoice = FindByName(__.IsInvoice); @@ -758,6 +768,9 @@ namespace COMCMS.Core /// 系统类型 public static readonly Field MyType = FindByName(__.MyType); + /// 支付成功流水号 + public static readonly Field OutTradeNo = FindByName(__.OutTradeNo); + static Field FindByName(String name) { return Meta.Table.FindByName(name); } } @@ -876,7 +889,7 @@ namespace COMCMS.Core public const String AddTime = "AddTime"; /// 下单IP - public const String IP = "IP"; + public const String Ip = "Ip"; /// 是否需要发票 public const String IsInvoice = "IsInvoice"; @@ -928,6 +941,9 @@ namespace COMCMS.Core /// 系统类型 public const String MyType = "MyType"; + + /// 支付成功流水号 + public const String OutTradeNo = "OutTradeNo"; } #endregion } @@ -1048,7 +1064,7 @@ namespace COMCMS.Core DateTime AddTime { get; set; } /// 下单IP - String IP { get; set; } + String Ip { get; set; } /// 是否需要发票 Int32 IsInvoice { get; set; } @@ -1100,6 +1116,9 @@ namespace COMCMS.Core /// 系统类型 Int32 MyType { get; set; } + + /// 支付成功流水号 + String OutTradeNo { get; set; } #endregion #region 获取/设置 字段值 diff --git a/COMCMS.Core/Weixin/公众平台回复信息.Biz.cs b/COMCMS.Core/Weixin/公众平台回复信息.Biz.cs new file mode 100644 index 0000000..bde8fe1 --- /dev/null +++ b/COMCMS.Core/Weixin/公众平台回复信息.Biz.cs @@ -0,0 +1,150 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; +using System.Web; +using System.Xml.Serialization; +using NewLife; +using NewLife.Data; +using NewLife.Log; +using NewLife.Model; +using NewLife.Reflection; +using NewLife.Threading; +using NewLife.Web; +using XCode; +using XCode.Cache; +using XCode.Configuration; +using XCode.DataAccessLayer; +using XCode.Membership; + +namespace COMCMS.Core +{ + /// 公众平台回复信息 + public partial class WeixinResponseContent : Entity + { + #region 对象操作 + static WeixinResponseContent() + { + + // 过滤器 UserModule、TimeModule、IPModule + Meta.Modules.Add(); + } + + /// 验证数据,通过抛出异常的方式提示验证失败。 + /// 是否插入 + public override void Valid(Boolean isNew) + { + // 如果没有脏数据,则不需要进行任何处理 + if (!HasDirty) return; + + // 在新插入数据或者修改了指定字段时进行修正 + //if (!Dirtys[nameof(UpdateTime)]) UpdateTime = DateTime.Now; + } + + ///// 首次连接数据库时初始化数据,仅用于实体类重载,用户不应该调用该方法 + //[EditorBrowsable(EditorBrowsableState.Never)] + //protected override void InitData() + //{ + // // InitData一般用于当数据表没有数据时添加一些默认数据,该实体类的任何第一次数据库操作都会触发该方法,默认异步调用 + // if (Meta.Session.Count > 0) return; + + // if (XTrace.Debug) XTrace.WriteLine("开始初始化WeixinResponseContent[公众平台回复信息]数据……"); + + // var entity = new WeixinResponseContent(); + // entity.Id = 0; + // entity.OpenId = "abc"; + // entity.RequestType = "abc"; + // entity.RequestContent = "abc"; + // entity.ResponseType = "abc"; + // entity.ReponseContent = "abc"; + // entity.XmlContent = "abc"; + // entity.UpdateTime = DateTime.Now; + // entity.Insert(); + + // if (XTrace.Debug) XTrace.WriteLine("完成初始化WeixinResponseContent[公众平台回复信息]数据!"); + //} + + ///// 已重载。基类先调用Valid(true)验证数据,然后在事务保护内调用OnInsert + ///// + //public override Int32 Insert() + //{ + // return base.Insert(); + //} + + ///// 已重载。在事务保护范围内处理业务,位于Valid之后 + ///// + //protected override Int32 OnDelete() + //{ + // return base.OnDelete(); + //} + #endregion + + #region 扩展属性 + #endregion + + #region 扩展查询 + /// 根据编号查找 + /// 编号 + /// 实体对象 + public static WeixinResponseContent FindById(Int32 id) + { + if (id <= 0) return null; + + // 实体缓存 + if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.Id == id); + + // 单对象缓存 + return Meta.SingleCache[id]; + + //return Find(_.Id == id); + } + #endregion + + #region 高级查询 + #endregion + + #region 业务操作 + #endregion + + #region 业务 + public static string GetResponseType(int typeid) + { + //Text = 0, + //Location = 1, + //Image = 2, + //Voice = 3, + //Video = 4, + //Link = 5, + //ShortVideo = 6, + //Event = 7, + + switch (typeid) + { + case 0: + return "text"; + case 1: + return "location"; + case 2: + return "image"; + case 3: + return "voice"; + case 4: + return "video"; + case 5: + return "link"; + case 6: + return "shortvideo"; + case 7: + return "event"; + default: + return "none"; + } + } + #endregion + } +} \ No newline at end of file diff --git a/COMCMS.Core/Weixin/公众平台回复信息.cs b/COMCMS.Core/Weixin/公众平台回复信息.cs new file mode 100644 index 0000000..abd10fb --- /dev/null +++ b/COMCMS.Core/Weixin/公众平台回复信息.cs @@ -0,0 +1,219 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using XCode; +using XCode.Configuration; +using XCode.DataAccessLayer; + +namespace COMCMS.Core +{ + /// 公众平台回复信息 + [Serializable] + [DataObject] + [Description("公众平台回复信息")] + [BindTable("WeixinResponseContent", Description = "公众平台回复信息", ConnName = "dbconn", DbType = DatabaseType.SqlServer)] + public partial class WeixinResponseContent : IWeixinResponseContent + { + #region 属性 + private Int32 _Id; + /// 编号 + [DisplayName("编号")] + [Description("编号")] + [DataObjectField(true, true, false, 0)] + [BindColumn("Id", "编号", "")] + public Int32 Id { get { return _Id; } set { if (OnPropertyChanging(__.Id, value)) { _Id = value; OnPropertyChanged(__.Id); } } } + + private String _OpenId; + /// 用户OpenId + [DisplayName("用户OpenId")] + [Description("用户OpenId")] + [DataObjectField(false, false, true, 50)] + [BindColumn("OpenId", "用户OpenId", "")] + public String OpenId { get { return _OpenId; } set { if (OnPropertyChanging(__.OpenId, value)) { _OpenId = value; OnPropertyChanged(__.OpenId); } } } + + private String _RequestType; + /// 请求类型 + [DisplayName("请求类型")] + [Description("请求类型")] + [DataObjectField(false, false, true, 50)] + [BindColumn("RequestType", "请求类型", "")] + public String RequestType { get { return _RequestType; } set { if (OnPropertyChanging(__.RequestType, value)) { _RequestType = value; OnPropertyChanged(__.RequestType); } } } + + private String _RequestContent; + /// 内容 + [DisplayName("内容")] + [Description("内容")] + [DataObjectField(false, false, true, -1)] + [BindColumn("RequestContent", "内容", "")] + public String RequestContent { get { return _RequestContent; } set { if (OnPropertyChanging(__.RequestContent, value)) { _RequestContent = value; OnPropertyChanged(__.RequestContent); } } } + + private String _ResponseType; + /// 回复的类型 文本消息:text 图片消息:image 地理位置消息:location 链接消息:link + [DisplayName("回复的类型文本消息:text图片消息:image地理位置消息:location链接消息:link")] + [Description("回复的类型 文本消息:text 图片消息:image 地理位置消息:location 链接消息:link")] + [DataObjectField(false, false, true, 50)] + [BindColumn("ResponseType", "回复的类型 文本消息:text 图片消息:image 地理位置消息:location 链接消息:link", "")] + public String ResponseType { get { return _ResponseType; } set { if (OnPropertyChanging(__.ResponseType, value)) { _ResponseType = value; OnPropertyChanged(__.ResponseType); } } } + + private String _ReponseContent; + /// 系统回复的内容 + [DisplayName("系统回复的内容")] + [Description("系统回复的内容")] + [DataObjectField(false, false, true, -1)] + [BindColumn("ReponseContent", "系统回复的内容", "")] + public String ReponseContent { get { return _ReponseContent; } set { if (OnPropertyChanging(__.ReponseContent, value)) { _ReponseContent = value; OnPropertyChanged(__.ReponseContent); } } } + + private String _XmlContent; + /// xml原始内容 + [DisplayName("xml原始内容")] + [Description("xml原始内容")] + [DataObjectField(false, false, true, -1)] + [BindColumn("XmlContent", "xml原始内容", "")] + public String XmlContent { get { return _XmlContent; } set { if (OnPropertyChanging(__.XmlContent, value)) { _XmlContent = value; OnPropertyChanged(__.XmlContent); } } } + + private DateTime _UpdateTime; + /// 修改时间 + [DisplayName("修改时间")] + [Description("修改时间")] + [DataObjectField(false, false, true, 0)] + [BindColumn("UpdateTime", "修改时间", "")] + public DateTime UpdateTime { get { return _UpdateTime; } set { if (OnPropertyChanging(__.UpdateTime, value)) { _UpdateTime = value; OnPropertyChanged(__.UpdateTime); } } } + #endregion + + #region 获取/设置 字段值 + /// 获取/设置 字段值 + /// 字段名 + /// + public override Object this[String name] + { + get + { + switch (name) + { + case __.Id : return _Id; + case __.OpenId : return _OpenId; + case __.RequestType : return _RequestType; + case __.RequestContent : return _RequestContent; + case __.ResponseType : return _ResponseType; + case __.ReponseContent : return _ReponseContent; + case __.XmlContent : return _XmlContent; + case __.UpdateTime : return _UpdateTime; + default: return base[name]; + } + } + set + { + switch (name) + { + case __.Id : _Id = value.ToInt(); break; + case __.OpenId : _OpenId = Convert.ToString(value); break; + case __.RequestType : _RequestType = Convert.ToString(value); break; + case __.RequestContent : _RequestContent = Convert.ToString(value); break; + case __.ResponseType : _ResponseType = Convert.ToString(value); break; + case __.ReponseContent : _ReponseContent = Convert.ToString(value); break; + case __.XmlContent : _XmlContent = Convert.ToString(value); break; + case __.UpdateTime : _UpdateTime = value.ToDateTime(); break; + default: base[name] = value; break; + } + } + } + #endregion + + #region 字段名 + /// 取得公众平台回复信息字段信息的快捷方式 + public partial class _ + { + /// 编号 + public static readonly Field Id = FindByName(__.Id); + + /// 用户OpenId + public static readonly Field OpenId = FindByName(__.OpenId); + + /// 请求类型 + public static readonly Field RequestType = FindByName(__.RequestType); + + /// 内容 + public static readonly Field RequestContent = FindByName(__.RequestContent); + + /// 回复的类型 文本消息:text 图片消息:image 地理位置消息:location 链接消息:link + public static readonly Field ResponseType = FindByName(__.ResponseType); + + /// 系统回复的内容 + public static readonly Field ReponseContent = FindByName(__.ReponseContent); + + /// xml原始内容 + public static readonly Field XmlContent = FindByName(__.XmlContent); + + /// 修改时间 + public static readonly Field UpdateTime = FindByName(__.UpdateTime); + + static Field FindByName(String name) { return Meta.Table.FindByName(name); } + } + + /// 取得公众平台回复信息字段名称的快捷方式 + public partial class __ + { + /// 编号 + public const String Id = "Id"; + + /// 用户OpenId + public const String OpenId = "OpenId"; + + /// 请求类型 + public const String RequestType = "RequestType"; + + /// 内容 + public const String RequestContent = "RequestContent"; + + /// 回复的类型 文本消息:text 图片消息:image 地理位置消息:location 链接消息:link + public const String ResponseType = "ResponseType"; + + /// 系统回复的内容 + public const String ReponseContent = "ReponseContent"; + + /// xml原始内容 + public const String XmlContent = "XmlContent"; + + /// 修改时间 + public const String UpdateTime = "UpdateTime"; + } + #endregion + } + + /// 公众平台回复信息接口 + public partial interface IWeixinResponseContent + { + #region 属性 + /// 编号 + Int32 Id { get; set; } + + /// 用户OpenId + String OpenId { get; set; } + + /// 请求类型 + String RequestType { get; set; } + + /// 内容 + String RequestContent { get; set; } + + /// 回复的类型 文本消息:text 图片消息:image 地理位置消息:location 链接消息:link + String ResponseType { get; set; } + + /// 系统回复的内容 + String ReponseContent { get; set; } + + /// xml原始内容 + String XmlContent { get; set; } + + /// 修改时间 + DateTime UpdateTime { get; set; } + #endregion + + #region 获取/设置 字段值 + /// 获取/设置 字段值 + /// 字段名 + /// + Object this[String name] { get; set; } + #endregion + } +} \ No newline at end of file diff --git a/COMCMS.Core/Weixin/微信公众号回复规则.Biz.cs b/COMCMS.Core/Weixin/微信公众号回复规则.Biz.cs new file mode 100644 index 0000000..f98b29d --- /dev/null +++ b/COMCMS.Core/Weixin/微信公众号回复规则.Biz.cs @@ -0,0 +1,235 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; +using System.Web; +using System.Xml.Serialization; +using NewLife; +using NewLife.Data; +using NewLife.Log; +using NewLife.Model; +using NewLife.Reflection; +using NewLife.Threading; +using NewLife.Web; +using XCode; +using XCode.Cache; +using XCode.Configuration; +using XCode.DataAccessLayer; +using XCode.Membership; + +namespace COMCMS.Core +{ + /// 微信公众号回复规则 + public partial class WeixinRequestRule : Entity + { + #region 对象操作 + static WeixinRequestRule() + { + // 累加字段 + //var df = Meta.Factory.AdditionalFields; + //df.Add(__.RequestType); + + // 过滤器 UserModule、TimeModule、IPModule + Meta.Modules.Add(); + } + + /// 验证数据,通过抛出异常的方式提示验证失败。 + /// 是否插入 + public override void Valid(Boolean isNew) + { + // 如果没有脏数据,则不需要进行任何处理 + if (!HasDirty) return; + + // 在新插入数据或者修改了指定字段时进行修正 + //if (!Dirtys[nameof(UpdateTime)]) UpdateTime = DateTime.Now; + } + + ///// 首次连接数据库时初始化数据,仅用于实体类重载,用户不应该调用该方法 + //[EditorBrowsable(EditorBrowsableState.Never)] + //protected override void InitData() + //{ + // // InitData一般用于当数据表没有数据时添加一些默认数据,该实体类的任何第一次数据库操作都会触发该方法,默认异步调用 + // if (Meta.Session.Count > 0) return; + + // if (XTrace.Debug) XTrace.WriteLine("开始初始化WeixinRequestRule[微信公众号回复规则]数据……"); + + // var entity = new WeixinRequestRule(); + // entity.Id = 0; + // entity.RuleName = "abc"; + // entity.Keywords = "abc"; + // entity.RequestType = 0; + // entity.ResponseType = 0; + // entity.IsLikeQuery = 0; + // entity.IsDefault = 0; + // entity.Rank = 0; + // entity.AddTime = DateTime.Now; + // entity.UpdateTime = DateTime.Now; + // entity.Insert(); + + // if (XTrace.Debug) XTrace.WriteLine("完成初始化WeixinRequestRule[微信公众号回复规则]数据!"); + //} + + ///// 已重载。基类先调用Valid(true)验证数据,然后在事务保护内调用OnInsert + ///// + //public override Int32 Insert() + //{ + // return base.Insert(); + //} + + ///// 已重载。在事务保护范围内处理业务,位于Valid之后 + ///// + //protected override Int32 OnDelete() + //{ + // return base.OnDelete(); + //} + #endregion + + #region 扩展属性 + private IList _ListContent; + /// + /// 详细规则列表 + /// + public IList ListContent + { + get + { + if (_ListContent == null && Id > 0 && !Dirtys["ListWechatRequestContent_" + Id]) + { + _ListContent = WeixinRequestContent.FindAll(WeixinRequestContent._.RuleId == Id, WeixinRequestContent._.Rank.Asc(), null, 0, 0); + + Dirtys["ListWechatRequestContent_" + Id] = true; + } + return _ListContent; + } + set { _ListContent = value; } + } + #endregion + + #region 扩展查询 + /// 根据编号查找 + /// 编号 + /// 实体对象 + public static WeixinRequestRule FindById(Int32 id) + { + if (id <= 0) return null; + + // 实体缓存 + if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.Id == id); + + // 单对象缓存 + return Meta.SingleCache[id]; + + //return Find(_.Id == id); + } + #endregion + + #region 高级查询 + #endregion + + #region 业务操作 + #endregion + + #region 业务 + /// + /// 微信请求类型 + /// 0默认回复1文字2图片3语音4链接5地理位置6关注7取消关注8扫描带参数二维码事件9上报地理位置事件10自定义菜单事件 + /// + public enum XRequestType + { + /// 默认回复 + Default = 0, + /// + /// 文本请求 + /// + Text = 1, + /// + /// 图片 + /// + Image = 2, + /// + /// 语音 + /// + Voice = 3, + /// + /// 链接 + /// + Link = 4, + /// + /// 地理位置 + /// + Location = 5, + /// + /// 关注 + /// + Flow = 6, + /// + /// 取消关注 + /// + Unflow = 7, + /// + /// 扫描二维码 + /// + Scan = 8, + /// + /// 上报地理位置 + /// + ReportingLocation = 9, + /// + /// 自定义菜单 + /// + CustomMenu = 10, + /// + /// 没找到关键字 + /// + NotFindKeyword = 11 + } + /// + /// 回复类型 + /// + public enum XResponseType + { + /// + /// 文本 + /// + Text = 0, + /// + /// 地理位置 + /// + Location = 1, + /// + /// 图片 + /// + Image = 2, + /// + /// 语音 + /// + Voice = 3, + /// + /// 视频 + /// + Video = 4, + /// + /// 链接 + /// + Link = 5, + /// + /// 短片 + /// + ShortVideo = 6, + /// + /// 自定义事件 + /// + Event = 7, + /// + /// 单张图片 + /// + SingleImage = 8, + } + #endregion + } +} \ No newline at end of file diff --git a/COMCMS.Core/Weixin/微信公众号回复规则.cs b/COMCMS.Core/Weixin/微信公众号回复规则.cs new file mode 100644 index 0000000..0034813 --- /dev/null +++ b/COMCMS.Core/Weixin/微信公众号回复规则.cs @@ -0,0 +1,257 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using XCode; +using XCode.Configuration; +using XCode.DataAccessLayer; + +namespace COMCMS.Core +{ + /// 微信公众号回复规则 + [Serializable] + [DataObject] + [Description("微信公众号回复规则")] + [BindTable("WeixinRequestRule", Description = "微信公众号回复规则", ConnName = "dbconn", DbType = DatabaseType.SqlServer)] + public partial class WeixinRequestRule : IWeixinRequestRule + { + #region 属性 + private Int32 _Id; + /// 编号 + [DisplayName("编号")] + [Description("编号")] + [DataObjectField(true, true, false, 0)] + [BindColumn("Id", "编号", "")] + public Int32 Id { get { return _Id; } set { if (OnPropertyChanging(__.Id, value)) { _Id = value; OnPropertyChanged(__.Id); } } } + + private String _RuleName; + /// 规则名称 + [DisplayName("规则名称")] + [Description("规则名称")] + [DataObjectField(false, false, true, 50)] + [BindColumn("RuleName", "规则名称", "")] + public String RuleName { get { return _RuleName; } set { if (OnPropertyChanging(__.RuleName, value)) { _RuleName = value; OnPropertyChanged(__.RuleName); } } } + + private String _Keywords; + /// 请求关键词,逗号分隔 + [DisplayName("请求关键词")] + [Description("请求关键词,逗号分隔")] + [DataObjectField(false, false, true, 200)] + [BindColumn("Keywords", "请求关键词,逗号分隔", "")] + public String Keywords { get { return _Keywords; } set { if (OnPropertyChanging(__.Keywords, value)) { _Keywords = value; OnPropertyChanged(__.Keywords); } } } + + private Int32 _RequestType; + /// 请求类型(0默认回复1文字2图片3语音4链接5地理位置6关注7取消关注8扫描带参数二维码事件9上报地理位置事件10自定义菜单事件) + [DisplayName("请求类型")] + [Description("请求类型(0默认回复1文字2图片3语音4链接5地理位置6关注7取消关注8扫描带参数二维码事件9上报地理位置事件10自定义菜单事件)")] + [DataObjectField(false, false, false, 0)] + [BindColumn("RequestType", "请求类型(0默认回复1文字2图片3语音4链接5地理位置6关注7取消关注8扫描带参数二维码事件9上报地理位置事件10自定义菜单事件)", "")] + public Int32 RequestType { get { return _RequestType; } set { if (OnPropertyChanging(__.RequestType, value)) { _RequestType = value; OnPropertyChanged(__.RequestType); } } } + + private Int32 _ResponseType; + /// 回复类型(1文本2图文3语音4视频5第三方接口) + [DisplayName("回复类型")] + [Description("回复类型(1文本2图文3语音4视频5第三方接口)")] + [DataObjectField(false, false, false, 0)] + [BindColumn("ResponseType", "回复类型(1文本2图文3语音4视频5第三方接口)", "")] + public Int32 ResponseType { get { return _ResponseType; } set { if (OnPropertyChanging(__.ResponseType, value)) { _ResponseType = value; OnPropertyChanged(__.ResponseType); } } } + + private Int32 _IsLikeQuery; + /// 是否模糊查询 0 是完全匹配;1是模糊匹配 + [DisplayName("是否模糊查询0是完全匹配;1是模糊匹配")] + [Description("是否模糊查询 0 是完全匹配;1是模糊匹配")] + [DataObjectField(false, false, false, 0)] + [BindColumn("IsLikeQuery", "是否模糊查询 0 是完全匹配;1是模糊匹配", "")] + public Int32 IsLikeQuery { get { return _IsLikeQuery; } set { if (OnPropertyChanging(__.IsLikeQuery, value)) { _IsLikeQuery = value; OnPropertyChanged(__.IsLikeQuery); } } } + + private Int32 _IsDefault; + /// 是否是默认回复 + [DisplayName("是否是默认回复")] + [Description("是否是默认回复")] + [DataObjectField(false, false, false, 0)] + [BindColumn("IsDefault", "是否是默认回复", "")] + public Int32 IsDefault { get { return _IsDefault; } set { if (OnPropertyChanging(__.IsDefault, value)) { _IsDefault = value; OnPropertyChanged(__.IsDefault); } } } + + private Int32 _Rank; + /// 排序 + [DisplayName("排序")] + [Description("排序")] + [DataObjectField(false, false, false, 0)] + [BindColumn("Rank", "排序", "")] + public Int32 Rank { get { return _Rank; } set { if (OnPropertyChanging(__.Rank, value)) { _Rank = value; OnPropertyChanged(__.Rank); } } } + + private DateTime _AddTime; + /// 添加时间 + [DisplayName("添加时间")] + [Description("添加时间")] + [DataObjectField(false, false, true, 0)] + [BindColumn("AddTime", "添加时间", "")] + public DateTime AddTime { get { return _AddTime; } set { if (OnPropertyChanging(__.AddTime, value)) { _AddTime = value; OnPropertyChanged(__.AddTime); } } } + + private DateTime _UpdateTime; + /// 修改时间 + [DisplayName("修改时间")] + [Description("修改时间")] + [DataObjectField(false, false, true, 0)] + [BindColumn("UpdateTime", "修改时间", "")] + public DateTime UpdateTime { get { return _UpdateTime; } set { if (OnPropertyChanging(__.UpdateTime, value)) { _UpdateTime = value; OnPropertyChanged(__.UpdateTime); } } } + #endregion + + #region 获取/设置 字段值 + /// 获取/设置 字段值 + /// 字段名 + /// + public override Object this[String name] + { + get + { + switch (name) + { + case __.Id : return _Id; + case __.RuleName : return _RuleName; + case __.Keywords : return _Keywords; + case __.RequestType : return _RequestType; + case __.ResponseType : return _ResponseType; + case __.IsLikeQuery : return _IsLikeQuery; + case __.IsDefault : return _IsDefault; + case __.Rank : return _Rank; + case __.AddTime : return _AddTime; + case __.UpdateTime : return _UpdateTime; + default: return base[name]; + } + } + set + { + switch (name) + { + case __.Id : _Id = value.ToInt(); break; + case __.RuleName : _RuleName = Convert.ToString(value); break; + case __.Keywords : _Keywords = Convert.ToString(value); break; + case __.RequestType : _RequestType = value.ToInt(); break; + case __.ResponseType : _ResponseType = value.ToInt(); break; + case __.IsLikeQuery : _IsLikeQuery = value.ToInt(); break; + case __.IsDefault : _IsDefault = value.ToInt(); break; + case __.Rank : _Rank = value.ToInt(); break; + case __.AddTime : _AddTime = value.ToDateTime(); break; + case __.UpdateTime : _UpdateTime = value.ToDateTime(); break; + default: base[name] = value; break; + } + } + } + #endregion + + #region 字段名 + /// 取得微信公众号回复规则字段信息的快捷方式 + public partial class _ + { + /// 编号 + public static readonly Field Id = FindByName(__.Id); + + /// 规则名称 + public static readonly Field RuleName = FindByName(__.RuleName); + + /// 请求关键词,逗号分隔 + public static readonly Field Keywords = FindByName(__.Keywords); + + /// 请求类型(0默认回复1文字2图片3语音4链接5地理位置6关注7取消关注8扫描带参数二维码事件9上报地理位置事件10自定义菜单事件) + public static readonly Field RequestType = FindByName(__.RequestType); + + /// 回复类型(1文本2图文3语音4视频5第三方接口) + public static readonly Field ResponseType = FindByName(__.ResponseType); + + /// 是否模糊查询 0 是完全匹配;1是模糊匹配 + public static readonly Field IsLikeQuery = FindByName(__.IsLikeQuery); + + /// 是否是默认回复 + public static readonly Field IsDefault = FindByName(__.IsDefault); + + /// 排序 + public static readonly Field Rank = FindByName(__.Rank); + + /// 添加时间 + public static readonly Field AddTime = FindByName(__.AddTime); + + /// 修改时间 + public static readonly Field UpdateTime = FindByName(__.UpdateTime); + + static Field FindByName(String name) { return Meta.Table.FindByName(name); } + } + + /// 取得微信公众号回复规则字段名称的快捷方式 + public partial class __ + { + /// 编号 + public const String Id = "Id"; + + /// 规则名称 + public const String RuleName = "RuleName"; + + /// 请求关键词,逗号分隔 + public const String Keywords = "Keywords"; + + /// 请求类型(0默认回复1文字2图片3语音4链接5地理位置6关注7取消关注8扫描带参数二维码事件9上报地理位置事件10自定义菜单事件) + public const String RequestType = "RequestType"; + + /// 回复类型(1文本2图文3语音4视频5第三方接口) + public const String ResponseType = "ResponseType"; + + /// 是否模糊查询 0 是完全匹配;1是模糊匹配 + public const String IsLikeQuery = "IsLikeQuery"; + + /// 是否是默认回复 + public const String IsDefault = "IsDefault"; + + /// 排序 + public const String Rank = "Rank"; + + /// 添加时间 + public const String AddTime = "AddTime"; + + /// 修改时间 + public const String UpdateTime = "UpdateTime"; + } + #endregion + } + + /// 微信公众号回复规则接口 + public partial interface IWeixinRequestRule + { + #region 属性 + /// 编号 + Int32 Id { get; set; } + + /// 规则名称 + String RuleName { get; set; } + + /// 请求关键词,逗号分隔 + String Keywords { get; set; } + + /// 请求类型(0默认回复1文字2图片3语音4链接5地理位置6关注7取消关注8扫描带参数二维码事件9上报地理位置事件10自定义菜单事件) + Int32 RequestType { get; set; } + + /// 回复类型(1文本2图文3语音4视频5第三方接口) + Int32 ResponseType { get; set; } + + /// 是否模糊查询 0 是完全匹配;1是模糊匹配 + Int32 IsLikeQuery { get; set; } + + /// 是否是默认回复 + Int32 IsDefault { get; set; } + + /// 排序 + Int32 Rank { get; set; } + + /// 添加时间 + DateTime AddTime { get; set; } + + /// 修改时间 + DateTime UpdateTime { get; set; } + #endregion + + #region 获取/设置 字段值 + /// 获取/设置 字段值 + /// 字段名 + /// + Object this[String name] { get; set; } + #endregion + } +} \ No newline at end of file diff --git a/COMCMS.Core/Weixin/请求回复的内容.Biz.cs b/COMCMS.Core/Weixin/请求回复的内容.Biz.cs new file mode 100644 index 0000000..07ab3a0 --- /dev/null +++ b/COMCMS.Core/Weixin/请求回复的内容.Biz.cs @@ -0,0 +1,123 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; +using System.Web; +using System.Xml.Serialization; +using NewLife; +using NewLife.Data; +using NewLife.Log; +using NewLife.Model; +using NewLife.Reflection; +using NewLife.Threading; +using NewLife.Web; +using XCode; +using XCode.Cache; +using XCode.Configuration; +using XCode.DataAccessLayer; +using XCode.Membership; + +namespace COMCMS.Core +{ + /// 请求回复的内容 + public partial class WeixinRequestContent : Entity + { + #region 对象操作 + static WeixinRequestContent() + { + // 累加字段 + //var df = Meta.Factory.AdditionalFields; + //df.Add(__.RuleId); + + // 过滤器 UserModule、TimeModule、IPModule + Meta.Modules.Add(); + } + + /// 验证数据,通过抛出异常的方式提示验证失败。 + /// 是否插入 + public override void Valid(Boolean isNew) + { + // 如果没有脏数据,则不需要进行任何处理 + if (!HasDirty) return; + + // 在新插入数据或者修改了指定字段时进行修正 + //if (!Dirtys[nameof(UpdateTime)]) UpdateTime = DateTime.Now; + } + + ///// 首次连接数据库时初始化数据,仅用于实体类重载,用户不应该调用该方法 + //[EditorBrowsable(EditorBrowsableState.Never)] + //protected override void InitData() + //{ + // // InitData一般用于当数据表没有数据时添加一些默认数据,该实体类的任何第一次数据库操作都会触发该方法,默认异步调用 + // if (Meta.Session.Count > 0) return; + + // if (XTrace.Debug) XTrace.WriteLine("开始初始化WeixinRequestContent[请求回复的内容]数据……"); + + // var entity = new WeixinRequestContent(); + // entity.Id = 0; + // entity.RuleId = 0; + // entity.Title = "abc"; + // entity.Content = "abc"; + // entity.LinkUrl = "abc"; + // entity.ImgURL = "abc"; + // entity.MediaURL = "abc"; + // entity.MeidaHdURL = "abc"; + // entity.MediaID = "abc"; + // entity.WXAppAppId = "abc"; + // entity.WXAppPage = "abc"; + // entity.Rank = 0; + // entity.AddTime = DateTime.Now; + // entity.UpdateTime = DateTime.Now; + // entity.Insert(); + + // if (XTrace.Debug) XTrace.WriteLine("完成初始化WeixinRequestContent[请求回复的内容]数据!"); + //} + + ///// 已重载。基类先调用Valid(true)验证数据,然后在事务保护内调用OnInsert + ///// + //public override Int32 Insert() + //{ + // return base.Insert(); + //} + + ///// 已重载。在事务保护范围内处理业务,位于Valid之后 + ///// + //protected override Int32 OnDelete() + //{ + // return base.OnDelete(); + //} + #endregion + + #region 扩展属性 + #endregion + + #region 扩展查询 + /// 根据编号查找 + /// 编号 + /// 实体对象 + public static WeixinRequestContent FindById(Int32 id) + { + if (id <= 0) return null; + + // 实体缓存 + if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.Id == id); + + // 单对象缓存 + return Meta.SingleCache[id]; + + //return Find(_.Id == id); + } + #endregion + + #region 高级查询 + #endregion + + #region 业务操作 + #endregion + } +} \ No newline at end of file diff --git a/COMCMS.Core/Weixin/请求回复的内容.cs b/COMCMS.Core/Weixin/请求回复的内容.cs new file mode 100644 index 0000000..552c085 --- /dev/null +++ b/COMCMS.Core/Weixin/请求回复的内容.cs @@ -0,0 +1,333 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using XCode; +using XCode.Configuration; +using XCode.DataAccessLayer; + +namespace COMCMS.Core +{ + /// 请求回复的内容 + [Serializable] + [DataObject] + [Description("请求回复的内容")] + [BindTable("WeixinRequestContent", Description = "请求回复的内容", ConnName = "dbconn", DbType = DatabaseType.SqlServer)] + public partial class WeixinRequestContent : IWeixinRequestContent + { + #region 属性 + private Int32 _Id; + /// 编号 + [DisplayName("编号")] + [Description("编号")] + [DataObjectField(true, true, false, 0)] + [BindColumn("Id", "编号", "")] + public Int32 Id { get { return _Id; } set { if (OnPropertyChanging(__.Id, value)) { _Id = value; OnPropertyChanged(__.Id); } } } + + private Int32 _RuleId; + /// 规则名称 + [DisplayName("规则名称")] + [Description("规则名称")] + [DataObjectField(false, false, false, 0)] + [BindColumn("RuleId", "规则名称", "")] + public Int32 RuleId { get { return _RuleId; } set { if (OnPropertyChanging(__.RuleId, value)) { _RuleId = value; OnPropertyChanged(__.RuleId); } } } + + private String _Title; + /// 回复标题 + [DisplayName("回复标题")] + [Description("回复标题")] + [DataObjectField(false, false, true, 250)] + [BindColumn("Title", "回复标题", "", Master = true)] + public String Title { get { return _Title; } set { if (OnPropertyChanging(__.Title, value)) { _Title = value; OnPropertyChanged(__.Title); } } } + + private String _Content; + /// 回复内容 + [DisplayName("回复内容")] + [Description("回复内容")] + [DataObjectField(false, false, true, -1)] + [BindColumn("Content", "回复内容", "")] + public String Content { get { return _Content; } set { if (OnPropertyChanging(__.Content, value)) { _Content = value; OnPropertyChanged(__.Content); } } } + + private String _LinkUrl; + /// 详情链接地址 + [DisplayName("详情链接地址")] + [Description("详情链接地址")] + [DataObjectField(false, false, true, 250)] + [BindColumn("LinkUrl", "详情链接地址", "")] + public String LinkUrl { get { return _LinkUrl; } set { if (OnPropertyChanging(__.LinkUrl, value)) { _LinkUrl = value; OnPropertyChanged(__.LinkUrl); } } } + + private String _ImgURL; + /// 图片地址 + [DisplayName("图片地址")] + [Description("图片地址")] + [DataObjectField(false, false, true, 250)] + [BindColumn("ImgURL", "图片地址", "")] + public String ImgURL { get { return _ImgURL; } set { if (OnPropertyChanging(__.ImgURL, value)) { _ImgURL = value; OnPropertyChanged(__.ImgURL); } } } + + private String _MediaURL; + /// 语音或视频地址 + [DisplayName("语音或视频地址")] + [Description("语音或视频地址")] + [DataObjectField(false, false, true, 250)] + [BindColumn("MediaURL", "语音或视频地址", "")] + public String MediaURL { get { return _MediaURL; } set { if (OnPropertyChanging(__.MediaURL, value)) { _MediaURL = value; OnPropertyChanged(__.MediaURL); } } } + + private String _MeidaHdURL; + /// 高清语音或者视频地址 + [DisplayName("高清语音或者视频地址")] + [Description("高清语音或者视频地址")] + [DataObjectField(false, false, true, 250)] + [BindColumn("MeidaHdURL", "高清语音或者视频地址", "")] + public String MeidaHdURL { get { return _MeidaHdURL; } set { if (OnPropertyChanging(__.MeidaHdURL, value)) { _MeidaHdURL = value; OnPropertyChanged(__.MeidaHdURL); } } } + + private String _MediaID; + /// 返回的素材ID + [DisplayName("返回的素材ID")] + [Description("返回的素材ID")] + [DataObjectField(false, false, true, 100)] + [BindColumn("MediaID", "返回的素材ID", "")] + public String MediaID { get { return _MediaID; } set { if (OnPropertyChanging(__.MediaID, value)) { _MediaID = value; OnPropertyChanged(__.MediaID); } } } + + private String _WXAppAppId; + /// 小程序APPId + [DisplayName("小程序APPId")] + [Description("小程序APPId")] + [DataObjectField(false, false, true, 100)] + [BindColumn("WXAppAppId", "小程序APPId", "")] + public String WXAppAppId { get { return _WXAppAppId; } set { if (OnPropertyChanging(__.WXAppAppId, value)) { _WXAppAppId = value; OnPropertyChanged(__.WXAppAppId); } } } + + private String _WXAppPage; + /// 小程序页面 + [DisplayName("小程序页面")] + [Description("小程序页面")] + [DataObjectField(false, false, true, 100)] + [BindColumn("WXAppPage", "小程序页面", "")] + public String WXAppPage { get { return _WXAppPage; } set { if (OnPropertyChanging(__.WXAppPage, value)) { _WXAppPage = value; OnPropertyChanged(__.WXAppPage); } } } + + private Int32 _Rank; + /// 排序 + [DisplayName("排序")] + [Description("排序")] + [DataObjectField(false, false, false, 0)] + [BindColumn("Rank", "排序", "")] + public Int32 Rank { get { return _Rank; } set { if (OnPropertyChanging(__.Rank, value)) { _Rank = value; OnPropertyChanged(__.Rank); } } } + + private DateTime _AddTime; + /// 添加时间 + [DisplayName("添加时间")] + [Description("添加时间")] + [DataObjectField(false, false, true, 0)] + [BindColumn("AddTime", "添加时间", "")] + public DateTime AddTime { get { return _AddTime; } set { if (OnPropertyChanging(__.AddTime, value)) { _AddTime = value; OnPropertyChanged(__.AddTime); } } } + + private DateTime _UpdateTime; + /// 修改时间 + [DisplayName("修改时间")] + [Description("修改时间")] + [DataObjectField(false, false, true, 0)] + [BindColumn("UpdateTime", "修改时间", "")] + public DateTime UpdateTime { get { return _UpdateTime; } set { if (OnPropertyChanging(__.UpdateTime, value)) { _UpdateTime = value; OnPropertyChanged(__.UpdateTime); } } } + #endregion + + #region 获取/设置 字段值 + /// 获取/设置 字段值 + /// 字段名 + /// + public override Object this[String name] + { + get + { + switch (name) + { + case __.Id : return _Id; + case __.RuleId : return _RuleId; + case __.Title : return _Title; + case __.Content : return _Content; + case __.LinkUrl : return _LinkUrl; + case __.ImgURL : return _ImgURL; + case __.MediaURL : return _MediaURL; + case __.MeidaHdURL : return _MeidaHdURL; + case __.MediaID : return _MediaID; + case __.WXAppAppId : return _WXAppAppId; + case __.WXAppPage : return _WXAppPage; + case __.Rank : return _Rank; + case __.AddTime : return _AddTime; + case __.UpdateTime : return _UpdateTime; + default: return base[name]; + } + } + set + { + switch (name) + { + case __.Id : _Id = value.ToInt(); break; + case __.RuleId : _RuleId = value.ToInt(); break; + case __.Title : _Title = Convert.ToString(value); break; + case __.Content : _Content = Convert.ToString(value); break; + case __.LinkUrl : _LinkUrl = Convert.ToString(value); break; + case __.ImgURL : _ImgURL = Convert.ToString(value); break; + case __.MediaURL : _MediaURL = Convert.ToString(value); break; + case __.MeidaHdURL : _MeidaHdURL = Convert.ToString(value); break; + case __.MediaID : _MediaID = Convert.ToString(value); break; + case __.WXAppAppId : _WXAppAppId = Convert.ToString(value); break; + case __.WXAppPage : _WXAppPage = Convert.ToString(value); break; + case __.Rank : _Rank = value.ToInt(); break; + case __.AddTime : _AddTime = value.ToDateTime(); break; + case __.UpdateTime : _UpdateTime = value.ToDateTime(); break; + default: base[name] = value; break; + } + } + } + #endregion + + #region 字段名 + /// 取得请求回复的内容字段信息的快捷方式 + public partial class _ + { + /// 编号 + public static readonly Field Id = FindByName(__.Id); + + /// 规则名称 + public static readonly Field RuleId = FindByName(__.RuleId); + + /// 回复标题 + public static readonly Field Title = FindByName(__.Title); + + /// 回复内容 + public static readonly Field Content = FindByName(__.Content); + + /// 详情链接地址 + public static readonly Field LinkUrl = FindByName(__.LinkUrl); + + /// 图片地址 + public static readonly Field ImgURL = FindByName(__.ImgURL); + + /// 语音或视频地址 + public static readonly Field MediaURL = FindByName(__.MediaURL); + + /// 高清语音或者视频地址 + public static readonly Field MeidaHdURL = FindByName(__.MeidaHdURL); + + /// 返回的素材ID + public static readonly Field MediaID = FindByName(__.MediaID); + + /// 小程序APPId + public static readonly Field WXAppAppId = FindByName(__.WXAppAppId); + + /// 小程序页面 + public static readonly Field WXAppPage = FindByName(__.WXAppPage); + + /// 排序 + public static readonly Field Rank = FindByName(__.Rank); + + /// 添加时间 + public static readonly Field AddTime = FindByName(__.AddTime); + + /// 修改时间 + public static readonly Field UpdateTime = FindByName(__.UpdateTime); + + static Field FindByName(String name) { return Meta.Table.FindByName(name); } + } + + /// 取得请求回复的内容字段名称的快捷方式 + public partial class __ + { + /// 编号 + public const String Id = "Id"; + + /// 规则名称 + public const String RuleId = "RuleId"; + + /// 回复标题 + public const String Title = "Title"; + + /// 回复内容 + public const String Content = "Content"; + + /// 详情链接地址 + public const String LinkUrl = "LinkUrl"; + + /// 图片地址 + public const String ImgURL = "ImgURL"; + + /// 语音或视频地址 + public const String MediaURL = "MediaURL"; + + /// 高清语音或者视频地址 + public const String MeidaHdURL = "MeidaHdURL"; + + /// 返回的素材ID + public const String MediaID = "MediaID"; + + /// 小程序APPId + public const String WXAppAppId = "WXAppAppId"; + + /// 小程序页面 + public const String WXAppPage = "WXAppPage"; + + /// 排序 + public const String Rank = "Rank"; + + /// 添加时间 + public const String AddTime = "AddTime"; + + /// 修改时间 + public const String UpdateTime = "UpdateTime"; + } + #endregion + } + + /// 请求回复的内容接口 + public partial interface IWeixinRequestContent + { + #region 属性 + /// 编号 + Int32 Id { get; set; } + + /// 规则名称 + Int32 RuleId { get; set; } + + /// 回复标题 + String Title { get; set; } + + /// 回复内容 + String Content { get; set; } + + /// 详情链接地址 + String LinkUrl { get; set; } + + /// 图片地址 + String ImgURL { get; set; } + + /// 语音或视频地址 + String MediaURL { get; set; } + + /// 高清语音或者视频地址 + String MeidaHdURL { get; set; } + + /// 返回的素材ID + String MediaID { get; set; } + + /// 小程序APPId + String WXAppAppId { get; set; } + + /// 小程序页面 + String WXAppPage { get; set; } + + /// 排序 + Int32 Rank { get; set; } + + /// 添加时间 + DateTime AddTime { get; set; } + + /// 修改时间 + DateTime UpdateTime { get; set; } + #endregion + + #region 获取/设置 字段值 + /// 获取/设置 字段值 + /// 字段名 + /// + Object this[String name] { get; set; } + #endregion + } +} \ No newline at end of file diff --git a/COMCMS.Web/Areas/AdminCP/Controllers/ArticleController.cs b/COMCMS.Web/Areas/AdminCP/Controllers/ArticleController.cs index af11af0..272ef8c 100644 --- a/COMCMS.Web/Areas/AdminCP/Controllers/ArticleController.cs +++ b/COMCMS.Web/Areas/AdminCP/Controllers/ArticleController.cs @@ -65,6 +65,34 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers tip.Message = "文章栏目标题不能为空!"; return Json(tip); } + if (string.IsNullOrEmpty(model.FilePath)) + { + tip.Message = "文章栏目路径不能为空!"; + return Json(tip); + } + + if (!model.FilePath.StartsWith("/")) + { + tip.Message = "栏目路径请以/开头!"; + return Json(tip); + } + if (model.FilePath.EndsWith("/")) + { + tip.Message = "栏目路径结尾不用加上/"; + return Json(tip); + } + if (model.FilePath.Count(x => x == '/') > 4) + { + tip.Message = "最多只能四级路径!"; + return Json(tip); + } + + if (!AdminUtils.CheckFilePathIsOK(model.FilePath, 0, 0)) + { + tip.Message = "栏目路径不可用,请重新填写!"; + return Json(tip); + } + model.Insert(); Core.Admin.WriteLogActions("添加文章栏目(id:" + model.Id + ");"); tip.Status = JsonTip.SUCCESS; @@ -127,6 +155,32 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers Json(tip); } + if (string.IsNullOrEmpty(model.FilePath)) + { + tip.Message = "文章栏目路径不能为空!"; + return Json(tip); + } + if (!model.FilePath.StartsWith("/")) + { + tip.Message = "栏目路径请以/开头!"; + return Json(tip); + } + if (model.FilePath.EndsWith("/")) + { + tip.Message = "栏目路径结尾不用加上/"; + return Json(tip); + } + if (model.FilePath.Count(x => x == '/') > 4) + { + tip.Message = "最多只能四级路径!"; + return Json(tip); + } + if (!AdminUtils.CheckFilePathIsOK(model.FilePath, entity.Id, 0)) + { + tip.Message = "栏目路径不可用,请重新填写!"; + return Json(tip); + } + if (entity.PId != model.PId) { if (entity.Id == model.PId) @@ -149,6 +203,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers alist.Save(); } } + bool idNeedUpdateAllArticleFilePath = entity.FilePath == model.FilePath; //赋值 entity.PId = model.PId; entity.KindName = model.KindName; @@ -171,9 +226,23 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers entity.KindDomain = model.KindDomain; entity.Rank = model.Rank; entity.Pic = model.Pic; + entity.FilePath = model.FilePath; entity.Save(); + //修改所有文章的路径 + if (idNeedUpdateAllArticleFilePath) + { + IList
listArticles = Article.FindAll(Article._.KId == entity.Id, null, null, 0, 0); + if(listArticles !=null && listArticles.Count > 0) + { + foreach (var item in listArticles) + { + item.FilePath = entity.FilePath; + } + listArticles.BatchUpdate(); + } + } Core.Admin.WriteLogActions("修改文章栏目(id:" + entity.Id + ");"); tip.Status = JsonTip.SUCCESS; tip.Message = "修改文章栏目成功"; @@ -276,8 +345,8 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers IList
list = Article.FindAll(ex, Article._.Sequence.Asc().And(Article._.Id.Desc()), null, startRowIndex, numPerPage); long totalCount = Article.FindCount(ex, Article._.Sequence.Asc().And(Article._.Id.Desc()), null, startRowIndex, numPerPage); - return Content(Newtonsoft.Json.JsonConvert.SerializeObject(new { total = totalCount, rows = list }), "text/plain"); - //return Json(new { total = totalCount, rows = list }, JsonRequestBehavior.AllowGet); + //return Content(Newtonsoft.Json.JsonConvert.SerializeObject(new { total = totalCount, rows = list }), "text/plain"); + return Json(new { total = totalCount, rows = list }); } //添加文章 @@ -414,8 +483,6 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers } } } - - //处理三个勾选属性的 string isnew = Request.Form["IsNew"]; model.IsNew = isnew == "1" ? 1 : 0; @@ -424,6 +491,8 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers string IsHide = Request.Form["IsHide"]; model.IsHide = IsHide == "1" ? 1 : 0; + //处理三个勾选属性的 + model.Hits = entity.Hits; model.UpdateTime = DateTime.Now; @@ -434,8 +503,43 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers content = ThumbnailHelper.SaveRemoteImgForContent(content); model.Content = content; } + + + entity.AddTime = model.AddTime; + entity.AdsId = model.AdsId; + entity.BannerImg = model.BannerImg; + entity.Content = model.Content; + entity.Description = model.Description; + entity.FilePath = model.FilePath; + entity.Hits = model.Hits; + entity.Icon = model.Icon; + entity.IsBest = model.IsBest; + entity.IsComment = model.IsComment; + entity.IsDel = model.IsDel; + entity.IsHide = model.IsHide; + entity.IsLock = model.IsLock; + entity.IsMember = model.IsMember; + entity.IsNew = model.IsNew; + entity.IsRecommend = model.IsRecommend; + entity.IsTop = model.IsTop; + entity.ItemImg = morIMG; + entity.Keyword = model.Keyword; + entity.KId = model.KId; + entity.LinkURL = model.LinkURL; + entity.Location = model.Location; + entity.Origin = model.Origin; + entity.OriginURL = model.OriginURL; + entity.Pic = model.Pic; + entity.Sequence = model.Sequence; + entity.SubTitle = model.SubTitle; + entity.Tags = model.Tags; + entity.TemplateFile = model.TemplateFile; + entity.Title = model.Title; + entity.TitleColor = model.TitleColor; + entity.UpdateTime = DateTime.Now; + //model.AuthorId = Core.Admin.GetMyInfo().Id; - model.Save(); + entity.Update(); //Tag.ModifyTags(model.Tags, RTType.RatuoModule.Article, model.Id, model.Title); Core.Admin.WriteLogActions("编辑文章(id:" + model.Id + ");"); tip.Status = JsonTip.SUCCESS; @@ -466,5 +570,131 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers return Json(tip); } #endregion + + #region 迁移文章 + [HttpGet] + [MyAuthorize("batch", "article")] + public IActionResult MoveArticle() + { + //获取上级栏目 + IList list = ArticleCategory.GetListTree(0, -1, true, false); + ViewBag.ListKinds = list; + return View(); + } + [HttpPost] + [MyAuthorize("batch", "article", "JSON")] + public IActionResult MoveArticle(int from, int to) + { + if (from <= 0 || to <= 0) + { + tip.Message = "请选择好栏目"; + return Json(tip); + } + if (from == to) + { + tip.Message = "迁移前后栏目一致,无法迁移"; + return Json(tip); + } + Article.Update("KId=" + to, "KId=" + from); + Core.Admin.WriteLogActions("迁移文章(from:" + from + ",to:" + to + ");"); + tip.Status = JsonTip.SUCCESS; + tip.Message = "迁移文章成功"; + tip.ReturnUrl = "close"; + return Json(tip); + } + #endregion + + #region 批量隐藏文章 + [HttpPost] + [MyAuthorize("batch", "article", "JSON")] + public IActionResult DoBatchHideArticle(string ids) + { + if (string.IsNullOrEmpty(ids)) + { + tip.Message = "请最少选择一篇文章!"; + return Json(tip); + } + List listIds = new List(); + try + { + listIds = JsonConvert.DeserializeObject>(ids); + } + catch (Exception ex) + { + tip.Message = "转换出错:" + ex.Message; + return Json(tip); + } + + if (listIds == null || listIds.Count < 1) + { + tip.Message = "请至少选择一篇文章!"; + return Json(tip); + } + + IList
list = Article.FindAll(Article._.Id.In(listIds), null, null, 0, 0); + if (list == null || list.Count < 1) + { + tip.Message = "请至少选择一篇文章!"; + return Json(tip); + } + + foreach (var item in list) + { + item.IsHide = 1; + } + + list.Update(); + Admin.WriteLogActions($"批量隐藏文章:{ids};"); + tip.Message = "批量隐藏文章成功!"; + tip.Status = JsonTip.SUCCESS; + return Json(tip); + } + #endregion + + #region 批量显示文章 + [HttpPost] + [MyAuthorize("batch", "article", "JSON")] + public IActionResult DoBatchShowArticle(string ids) + { + if (string.IsNullOrEmpty(ids)) + { + tip.Message = "请最少选择一篇文章!"; + return Json(tip); + } + List listIds = new List(); + try + { + listIds = JsonConvert.DeserializeObject>(ids); + } + catch (Exception ex) + { + tip.Message = "转换出错:" + ex.Message; + return Json(tip); + } + + if (listIds == null || listIds.Count < 1) + { + tip.Message = "请至少选择一篇文章!"; + return Json(tip); + } + + IList
list = Article.FindAll(Article._.Id.In(listIds), null, null, 0, 0); + if (list == null || list.Count < 1) + { + tip.Message = "请至少选择一篇文章!"; + return Json(tip); + } + + foreach (var item in list) + { + item.IsHide = 0; + } + list.Update(); + Admin.WriteLogActions($"批量显示文章:{ids};"); + tip.Message = "批量显示文章成功!"; + tip.Status = JsonTip.SUCCESS; + return Json(tip); + } + #endregion } } \ No newline at end of file diff --git a/COMCMS.Web/Areas/AdminCP/Controllers/GuestbookController.cs b/COMCMS.Web/Areas/AdminCP/Controllers/GuestbookController.cs index dfcef92..f09b963 100644 --- a/COMCMS.Web/Areas/AdminCP/Controllers/GuestbookController.cs +++ b/COMCMS.Web/Areas/AdminCP/Controllers/GuestbookController.cs @@ -9,13 +9,16 @@ using XCode; using Newtonsoft.Json; using COMCMS.Web.Common; using Microsoft.AspNetCore.Http; +using System.ComponentModel; namespace COMCMS.Web.Areas.AdminCP.Controllers { + [DisplayName("留言板")] public class GuestbookController : AdminBaseController { #region 留言板分类 [MyAuthorize("viewlist", "guestbookkinds")] + [DisplayName("留言分类")] public IActionResult GuestbookCategorys() { IList list = GuestbookCategory.FindAll(null, GuestbookCategory._.Rank.Asc(), null, 0, 0); @@ -93,12 +96,14 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers #region 留言列表 [MyAuthorize("viewlist", "guestbook")] + [DisplayName("留言列表")] public IActionResult GuestbookList() { IList list = GuestbookCategory.FindAll(null, GuestbookCategory._.Rank.Asc(), null, 0, 0); ViewBag.ListKinds = list; return View(); } + [MyAuthorize("viewlist", "guestbook","JSON")] public IActionResult GetGuesbookList(string keyword, int page = 1, int limit = 20) { diff --git a/COMCMS.Web/Areas/AdminCP/Controllers/IndexController.cs b/COMCMS.Web/Areas/AdminCP/Controllers/IndexController.cs index a9cc8d0..9074c0c 100644 --- a/COMCMS.Web/Areas/AdminCP/Controllers/IndexController.cs +++ b/COMCMS.Web/Areas/AdminCP/Controllers/IndexController.cs @@ -16,8 +16,8 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers [Area("AdminCP")] public class IndexController : AdminBaseController { - private readonly IHostingEnvironment _env; - public IndexController(IHostingEnvironment env) + private readonly IWebHostEnvironment _env; + public IndexController(IWebHostEnvironment env) { _env = env; } @@ -32,7 +32,6 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers Admin admin = Admin.GetMyInfo(); ViewBag.admin = admin; - //获取菜单 List list = new List(); //这里需要获取权限,暂时先所有 diff --git a/COMCMS.Web/Areas/AdminCP/Controllers/LoginController.cs b/COMCMS.Web/Areas/AdminCP/Controllers/LoginController.cs index ebb20d2..38bb7af 100644 --- a/COMCMS.Web/Areas/AdminCP/Controllers/LoginController.cs +++ b/COMCMS.Web/Areas/AdminCP/Controllers/LoginController.cs @@ -56,6 +56,12 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers } //判断并解密 string key = SessionHelper.GetSession("des_key").ToString(); + if (string.IsNullOrEmpty(key)) + { + tip.Message = "页面访问超时,请刷新页面重新登录!"; + tip.Other = "reload"; + return Json(tip); + } //解密 string username = ""; string password = ""; @@ -67,14 +73,15 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers catch (Exception exp) { NewLife.Log.XTrace.WriteException(exp); - tip.Message = "用户名或者密码错误!"; + tip.Message = "页面访问超时,请刷新页面重新登录!"; + tip.Other = "reload"; return Json(tip); } //验证用户 if (string.IsNullOrEmpty(username)) { - tip.Message = "请输入用户名!"+ key; + tip.Message = "请输入用户名!"; return Json(tip); } if (string.IsNullOrEmpty(password) || Utils.GetStringLength(password) < 5) @@ -115,8 +122,8 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers /// public IActionResult Logout() { - //Admin.ClearInfo(); - Admin.ClearInfoAsync().Wait(); + Admin.ClearInfo(); + //Admin.ClearInfoAsync().Wait(); return Redirect("~/AdminCP/Login"); } #endregion diff --git a/COMCMS.Web/Areas/AdminCP/Controllers/MemberController.cs b/COMCMS.Web/Areas/AdminCP/Controllers/MemberController.cs index 68e8c12..ba82051 100644 --- a/COMCMS.Web/Areas/AdminCP/Controllers/MemberController.cs +++ b/COMCMS.Web/Areas/AdminCP/Controllers/MemberController.cs @@ -592,6 +592,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers #region 用户组管理 [MyAuthorize( "viewlist", "memberrole")] + [DisplayName("用户组列表")] public IActionResult MemberRole() { IList list = MemberRoles.FindAll(MemberRoles._.Id > 0, MemberRoles._.Rank.Asc(), null, 0, 0); @@ -786,6 +787,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers #region 用户管理 [MyAuthorize("viewlist", "members")] + [DisplayName("用户列表")] public IActionResult Members() { //加载用户组 @@ -1026,11 +1028,12 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers #region 后台管理日志列表 [MyAuthorize("viewlist", "admincplog")] + [DisplayName("后台管理日志")] public IActionResult AdminCPLogList() { return View(); } - [MyAuthorize("viewlist", "admincplog")] + [MyAuthorize("viewlist", "admincplog","JSON")] public IActionResult GetAdminCPLogList(string keyword, int page = 1, int limit = 20) { int numPerPage, currentPage, startRowIndex; diff --git a/COMCMS.Web/Areas/AdminCP/Controllers/OrderController.cs b/COMCMS.Web/Areas/AdminCP/Controllers/OrderController.cs index 7a97714..5ecc56b 100644 --- a/COMCMS.Web/Areas/AdminCP/Controllers/OrderController.cs +++ b/COMCMS.Web/Areas/AdminCP/Controllers/OrderController.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; @@ -12,10 +13,12 @@ using Microsoft.AspNetCore.Http; namespace COMCMS.Web.Areas.AdminCP.Controllers { + [DisplayName("订单")] public class OrderController : AdminBaseController { #region 订单列表 [MyAuthorize("viewlist", "order")] + [DisplayName("订单列表")] public IActionResult OrderList() { Core.Admin.WriteLogActions("查看订单列表;"); @@ -298,6 +301,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers #region 在线支付成功记录 [MyAuthorize("viewlist", "payonline")] + [DisplayName("支付订单")] public IActionResult PayOnlineList() { Core.Admin.WriteLogActions("查看在线支付订单列表;"); diff --git a/COMCMS.Web/Areas/AdminCP/Controllers/OtherController.cs b/COMCMS.Web/Areas/AdminCP/Controllers/OtherController.cs index 289cf3a..f7fc3d9 100644 --- a/COMCMS.Web/Areas/AdminCP/Controllers/OtherController.cs +++ b/COMCMS.Web/Areas/AdminCP/Controllers/OtherController.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; @@ -13,11 +14,13 @@ using COMCMS.Core.Models; namespace COMCMS.Web.Areas.AdminCP.Controllers { + [DisplayName("其它")] public class OtherController : AdminBaseController { #region 广告分类管理 //查看&编辑广告分类(同一个页面执行) [MyAuthorize("viewlist", "adskinds")] + [DisplayName("广告分类")] public IActionResult AdsCategoryList() { IList list = AdsKind.FindAll(null, AdsKind._.Rank.Asc(), null, 0, 0); @@ -96,6 +99,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers #region 广告管理 [MyAuthorize("viewlist", "ads")] + [DisplayName("广告列表")] public IActionResult AdsList() { IList list = AdsKind.FindAll(null, AdsKind._.Rank.Asc(), null, 0, 0); @@ -528,6 +532,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers #region 友情链接分类管理 //查看&编辑友情链接分类(同一个页面执行) [MyAuthorize("viewlist", "adskinds")] + [DisplayName("友情链接分类")] public IActionResult LinkCategoryList() { IList list = LinkKind.FindAll(null, LinkKind._.Rank.Asc(), null, 0, 0); @@ -608,6 +613,8 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers #region 友情链接管理 //查看友情链接列表 [MyAuthorize("viewlist", "link")] + [DisplayName("友情链接列表")] + public IActionResult LinkList() { IList list = LinkKind.FindAll(null, LinkKind._.Rank.Asc(), null, 0, 0); diff --git a/COMCMS.Web/Areas/AdminCP/Controllers/PermissionController.cs b/COMCMS.Web/Areas/AdminCP/Controllers/PermissionController.cs index dc40bcb..536d6d7 100644 --- a/COMCMS.Web/Areas/AdminCP/Controllers/PermissionController.cs +++ b/COMCMS.Web/Areas/AdminCP/Controllers/PermissionController.cs @@ -10,6 +10,11 @@ using XCode; using Newtonsoft.Json; using COMCMS.Web.Common; using Microsoft.AspNetCore.Http; +using System.IO; +using NewLife.Log; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.FileProviders; +using System.Text; namespace COMCMS.Web.Areas.AdminCP.Controllers { @@ -17,6 +22,12 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers [DisplayName("后台权限")] public class PermissionController : AdminBaseController { + private IWebHostEnvironment _env; + public PermissionController(IWebHostEnvironment env) + { + _env = env; + } + #region 事件管理 /// /// 目标事件 @@ -329,5 +340,77 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers return Json(tip); } #endregion + + #region 系统运行日志 + [HttpGet] + [MyAuthorize("viewlist", "runlogs")] + [DisplayName("系统运行日志")] + public IActionResult RunLogs() + { + string logPath = $"{_env.ContentRootPath}{Path.DirectorySeparatorChar}Log{Path.DirectorySeparatorChar}"; + List lognames = new List(); + try + { + if (Directory.Exists(logPath)) + { + DirectoryInfo directory = new DirectoryInfo(logPath); + List listFiles = new List(); + DirectoryInfo[] directorys = directory.GetDirectories(); + FileInfo[] files; + files = directory.GetFiles(); + foreach (FileInfo file in files) + { + lognames.Add(file.Name); + } + } + } + catch (Exception ex) + { + XTrace.WriteException(ex); + } + lognames.Reverse();//倒序排列一下 + ViewBag.logPath = logPath; + return View(lognames); + } + #endregion + + #region 获取日志详情 + [HttpPost] + [MyAuthorize("viewlist", "runlogs")] + public async Task GetRunLogDetail(string logname) + { + if (string.IsNullOrEmpty(logname)) + { + return Content("错误日志名称!"); + } + string logPath = $"{_env.ContentRootPath}{Path.DirectorySeparatorChar}Log{Path.DirectorySeparatorChar}"; + string logFullPath = logPath + logname; + + + if (!System.IO.File.Exists(logFullPath)) + { + return Content("系统找不到本日志文件!"); + } + //XTrace.WriteLine("查看日志:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); + + IFileProvider fileProvider = new PhysicalFileProvider(logPath); + StringBuilder detail = new StringBuilder(); + using (Stream stream = fileProvider.GetFileInfo(logname).CreateReadStream()) + { + byte[] buffer = new byte[stream.Length]; + await stream.ReadAsync(buffer, 0, buffer.Length); + detail.Append(Encoding.Default.GetString(buffer)); + } + + + //using (StreamReader fs = new StreamReader(logFullPath)) + //{ + // detail.Append(fs.ReadToEndAsync()); + //} + + //string detail = await System.IO.File.ReadAllTextAsync(logFullPath); + return Content(detail.ToString()); + } + #endregion } } \ No newline at end of file diff --git a/COMCMS.Web/Areas/AdminCP/Controllers/ProductController.cs b/COMCMS.Web/Areas/AdminCP/Controllers/ProductController.cs index 90cd0cf..99367d2 100644 --- a/COMCMS.Web/Areas/AdminCP/Controllers/ProductController.cs +++ b/COMCMS.Web/Areas/AdminCP/Controllers/ProductController.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; @@ -12,6 +13,7 @@ using Microsoft.AspNetCore.Http; namespace COMCMS.Web.Areas.AdminCP.Controllers { + [DisplayName("商品")] public class ProductController : AdminBaseController { #region 商品栏目 @@ -20,6 +22,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers /// /// [MyAuthorize("viewlist", "category")] + [DisplayName("商品栏目")] public IActionResult CategoryList() { IList list = Category.GetListTree(0, -1, false, true); @@ -187,6 +190,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers #region 商品列表 [MyAuthorize("viewlist", "product")] + [DisplayName("商品列表")] public IActionResult ProductList() { //获取上级栏目 diff --git a/COMCMS.Web/Areas/AdminCP/Controllers/ServerController.cs b/COMCMS.Web/Areas/AdminCP/Controllers/ServerController.cs new file mode 100644 index 0000000..9d772c4 --- /dev/null +++ b/COMCMS.Web/Areas/AdminCP/Controllers/ServerController.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using COMCMS.Common; +using COMCMS.Core; +using XCode; +using Newtonsoft.Json; +using COMCMS.Web.Common; +using Microsoft.AspNetCore.Http; + +namespace COMCMS.Web.Areas.AdminCP.Controllers +{ + public class ServerController : AdminBaseController + { + #region 中文转拼音 + public IActionResult Hanzi2Pinyin(string name) + { + string pinyin = ""; + if (!string.IsNullOrEmpty(name)) + { + pinyin = PinYinHelper.GetPinyin(name).ToLower().Replace(" ","-"); + } + tip.Status = JsonTip.SUCCESS; + tip.Message = pinyin; + return Json(tip); + } + #endregion + } +} \ No newline at end of file diff --git a/COMCMS.Web/Areas/AdminCP/Controllers/SystemController.cs b/COMCMS.Web/Areas/AdminCP/Controllers/SystemController.cs index 8c5da32..224fc6b 100644 --- a/COMCMS.Web/Areas/AdminCP/Controllers/SystemController.cs +++ b/COMCMS.Web/Areas/AdminCP/Controllers/SystemController.cs @@ -19,8 +19,8 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers [Area("AdminCP")] public class SystemController : AdminBaseController { - private IHostingEnvironment _env; - public SystemController(IHostingEnvironment env) + private IWebHostEnvironment _env; + public SystemController(IWebHostEnvironment env) { _env = env; } diff --git a/COMCMS.Web/Areas/AdminCP/Controllers/UploadController.cs b/COMCMS.Web/Areas/AdminCP/Controllers/UploadController.cs index 3c75a9f..6fe4439 100644 --- a/COMCMS.Web/Areas/AdminCP/Controllers/UploadController.cs +++ b/COMCMS.Web/Areas/AdminCP/Controllers/UploadController.cs @@ -15,7 +15,6 @@ using COMCMS.Core.Models; using System.DrawingCore; using System.Text; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Internal; using Microsoft.Extensions.Primitives; using NewLife.UserGroup.WebUploader; @@ -47,9 +46,9 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers public class UploadController : AdminBaseController { private readonly SystemSetting _attachsetting; - private IHostingEnvironment _env; + private IWebHostEnvironment _env; private AttachConfigEntity attach; - public UploadController(IHostingEnvironment env, IOptions attachsetting) + public UploadController(IWebHostEnvironment env, IOptions attachsetting) { attach = Config.GetSystemConfig().AttachConfigEntity; _env = env; @@ -264,6 +263,8 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers imgPath = $"{DateTime.Now.Year.ToString()}{Path.DirectorySeparatorChar}{DateTime.Now.ToString("MM")}{Path.DirectorySeparatorChar}{DateTime.Now.ToString("dd")}"; break; } + filepath += imgPath;//存放路径 + thumbsFilePath += imgPath;//缩略图路径 //文件名字 string imgname = Utils.GetOrderNum() + Utils.GetFileExtName(upload.FileName); switch (attach.IsRandomFileName) @@ -357,7 +358,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers { fileName = imgname, uploaded = 1, - url = $"/{attach.AttachPatch}/images/{imgPath.Replace("\\", "/")}/" + imgname + url = $"/{attach.AttachPatch}/files/{imgPath.Replace("\\", "/")}/" + imgname }; return Json(successJson); //return Content(string.Format(tpl, $"/{attach.AttachPatch}/fales/{imgPath.Replace("\\", "/")}/" + imgname, callback, ""), "text/html"); @@ -422,7 +423,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers var req = HttpContext.Request; var f = Request.Form.Files[0]; - Request.EnableRewind(); + //Request.EnableRewind(); Image image = null; using (StreamReader reader = new StreamReader(req.Body, Encoding.UTF8, true, 1024, true)) { diff --git a/COMCMS.Web/Areas/AdminCP/Controllers/WeixinController.cs b/COMCMS.Web/Areas/AdminCP/Controllers/WeixinController.cs new file mode 100644 index 0000000..1584cf2 --- /dev/null +++ b/COMCMS.Web/Areas/AdminCP/Controllers/WeixinController.cs @@ -0,0 +1,1133 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using COMCMS.Common; +using COMCMS.Core; +using XCode; +using Newtonsoft.Json; +using COMCMS.Web.Common; +using Microsoft.AspNetCore.Http; +using Senparc.Weixin.MP.Entities; +using NewLife.Log; +using Senparc.Weixin.MP.Containers; +using Senparc.Weixin.MP.Entities.Menu; +using System.IO; +using System.Text; + +namespace COMCMS.Web.Areas.AdminCP.Controllers +{ + [DisplayName("微信公众号系统")] + [Description("微信公众号系统,包括关注自动回复、自定义菜单、关键字回复")] + public class WeixinController : AdminBaseController + { + + #region 自定义菜单 + //自定义菜单 + [MyAuthorize("view", "wxmenu")] + [HttpGet] + public IActionResult Menu() + { + + Config cfg = Config.GetSystemConfig(); + if(string.IsNullOrEmpty(cfg.AppId) || string.IsNullOrEmpty(cfg.AppSecret)) + { + return EchoTipPage("请先到【系统设置】> 【基本设置】 设置公众号AppId和AppSecret!"); + } + string accessToken = ""; + try + { + accessToken = AccessTokenContainer.TryGetAccessToken(cfg.AppId, cfg.AppSecret); + + } + catch (Exception ex) + { + return EchoTipPage(ex.Message); + } + + if (string.IsNullOrEmpty(accessToken)) + { + return EchoTipPage("AccessToken 获取错误,请确认微信配置没错。或者服务器没加入白名单!"); + } + //XTrace.WriteLine("当前AccessToken:" + accessToken); + //获取菜单 + GetMenuResult result = new GetMenuResult(new ButtonGroup()); + try + { + result = Senparc.Weixin.MP.CommonAPIs.CommonApi.GetMenu(accessToken); + if (result == null) + { + result = new GetMenuResult(new ButtonGroup()); + } + } + catch (Exception ex) + { + result = new GetMenuResult(new ButtonGroup()); + XTrace.WriteLine("获取菜单出错:" + ex.Message); + } + Core.Admin.WriteLogActions("查看公众号菜单;"); + return View(result); + } + //修改菜单 + [HttpPost] + [MyAuthorize("edit", "wxmenu", "JSON")] + public IActionResult DoPostMenuData(string allmenu) + { + + Config cfg = Config.GetSystemConfig(); + string accessToken = ""; + try + { + accessToken = AccessTokenContainer.TryGetAccessToken(cfg.AppId, cfg.AppSecret); + + } + catch (Exception ex) + { + tip.Message = ex.Message; + return Json(tip); + } + + if (string.IsNullOrEmpty(accessToken)) + { + tip.Message = "AccessToken 获取错误,请确认微信配置没错。或者服务器没加入白名单!"; + return Json(tip); + } + if (string.IsNullOrEmpty(allmenu)) + { + tip.Message = "请填写自定义菜单"; + return Json(tip); + } + //Senparc.Weixin.MP.CommonAPIs.CommonApi.CreateMenu() + string posturl = $"https://api.weixin.qq.com/cgi-bin/menu/create?access_token={accessToken}"; + + Stream retunStream = Utils.HttpPost(posturl, allmenu); + + StreamReader reader = new StreamReader(retunStream, Encoding.UTF8); + string value = reader.ReadToEnd(); + + reader.Close(); + + XTrace.WriteLine("创建公众号菜单回传:" + value); + + dynamic rejson = Newtonsoft.Json.Linq.JToken.Parse(value) as dynamic; + if (rejson != null && rejson.errcode == 0) + { + tip.Status = JsonTip.SUCCESS; + tip.Message = "创建/修改公众号菜单成功!"; + return Json(tip); + } + tip.Message = rejson.errmsg; + Core.Admin.WriteLogActions("修改公众号菜单;"); + return Json(tip); + } + #endregion + + #region 关注自动回复 + [HttpGet] + [MyAuthorize("edit", "wxautoreply")] + public IActionResult SubscribeReply() + { + + WeixinRequestRule ruleModel = WeixinRequestRule.Find(WeixinRequestRule._.RequestType == (int)WeixinRequestRule.XRequestType.Flow);//获取规则 + if (ruleModel == null) + { + ruleModel = new WeixinRequestRule(); + ruleModel.RequestType = (int)WeixinRequestRule.XRequestType.Flow; + ruleModel.ResponseType = (int)WeixinRequestRule.XResponseType.Text; + ruleModel.RuleName = "关注自动回复"; + ruleModel.IsDefault = 1; + ruleModel.Insert(); + //增加Response + WeixinRequestContent content = new WeixinRequestContent() + { + RuleId = ruleModel.Id, + Content = "关注公众号自动回复文本" + + }; + content.Insert(); + } + switch (ruleModel.ResponseType) + { + case 0://文本 + ViewBag.txtContent = ruleModel.ListContent[0].Content; + break; + case 1://多图 + break; + case 2://语音 + ViewBag.txtSoundTitle = ruleModel.ListContent[0].Title; + ViewBag.txtSoundUrl = ruleModel.ListContent[0].MediaURL; + ViewBag.txtSoundContent = ruleModel.ListContent[0].Content; + break; + case 8://单图 + ViewBag.txtSingleImage = ruleModel.ListContent[0].ImgURL; + break; + } + Admin.WriteLogActions("查看公众号关注自动回复;"); + return View(ruleModel); + } + //编辑自动回复规则 + [HttpPost] + [MyAuthorize("edit", "wxautoreply", "JSON")] + public IActionResult SubscribeReply(WeixinRequestRule entity) + { + WeixinRequestRule model = WeixinRequestRule.Find(WeixinRequestRule._.RequestType == (int)WeixinRequestRule.XRequestType.Flow);//获取规则 + model.ResponseType = entity.ResponseType; + + model.IsDefault = 1; + int defaultDetailId = int.Parse(Request.Form["hdfTID"]);//默认一条的ID。肯定至少有一条 + int responseType = model.ResponseType; + IList ls = new List(); + if (responseType == 0) //纯文本 + { + string txtContent = Request.Form["txtContent"]; + if (string.IsNullOrEmpty(txtContent)) + { + tip.Message = "文本回复,文本不能为空!"; + return Json(tip); + } + model.ResponseType = (int)WeixinRequestRule.XResponseType.Text;//回复的类型:文本1,图文2,语音3,视频4,第三方接口5 + ls.Add(new WeixinRequestContent { RuleId = model.Id, Content = txtContent.Trim(), Id = defaultDetailId}); + } + else if (responseType == (int)WeixinRequestRule.XResponseType.Image) //图文 + { + #region 赋值规则图片 + + string[] itemIdArr = Request.Form["item_id"]; + string[] itemTitleArr = Request.Form["item_title"]; + string[] itemContentArr = Request.Form["item_imginfo"]; + string[] itemImgUrlArr = Request.Form["item_imgurl"]; + string[] itemLinkUrlArr = Request.Form["item_linkurl"]; + if (itemIdArr != null && itemTitleArr != null && itemImgUrlArr != null && itemLinkUrlArr != null && itemContentArr != null) + { + if ((itemIdArr.Length == itemTitleArr.Length) && (itemTitleArr.Length == itemImgUrlArr.Length) && (itemImgUrlArr.Length == itemLinkUrlArr.Length)) + { + + for (int i = 0; i < itemIdArr.Length; i++) + { + if (!string.IsNullOrEmpty(itemTitleArr[i])) + { + WeixinRequestContent modelt = new WeixinRequestContent(); + modelt.Id = Utils.StrToInt(itemIdArr[i].Trim(), 0); + modelt.Title = itemTitleArr[i].Trim(); + modelt.Content = itemContentArr[i].Trim(); + modelt.ImgURL = itemImgUrlArr[i].Trim(); + modelt.LinkUrl = itemLinkUrlArr[i].Trim(); + modelt.RuleId = model.Id; + ls.Add(modelt); + } + } + //model.contents = ls; + } + } + #endregion + if (ls == null || ls.Count < 1) + { + tip.Message = "图文列表,图文项目不能为空!"; + return Json(tip); + } + + } + else if (responseType == (int)WeixinRequestRule.XResponseType.Video) //语音 + { + string txtSoundTitle = Request.Form["txtSoundTitle"]; + if (string.IsNullOrEmpty(txtSoundTitle)) + { + tip.Message = "语音回复,语音标题不能为空!"; + return Json(tip); + } + string txtSoundUrl = Request.Form["txtSoundUrl"]; + if (string.IsNullOrEmpty(txtSoundUrl)) + { + tip.Message = "语音回复,语音地址不能为空!"; + return Json(tip); + } + string txtSoundContent = Request.Form["txtSoundContent"]; + + ls.Add(new WeixinRequestContent { RuleId = model.Id, MediaURL = txtSoundUrl.Trim(), Title = txtSoundTitle, Id = defaultDetailId, Content = txtSoundContent }); + } + else if (responseType == (int)WeixinRequestRule.XResponseType.SingleImage) //单图片 + { + string txtSingleImage = Request.Form["txtSingleImage"]; + if (string.IsNullOrEmpty(txtSingleImage)) + { + tip.Message = "单图片回复,图片地址不能为空!"; + return Json(tip); + } + ls.Add(new WeixinRequestContent { RuleId = model.Id, ImgURL = txtSingleImage.Trim(), Id = defaultDetailId}); + } + model.Save(); + IList oldwc = model.ListContent; + if (oldwc != null && oldwc.Count > 0) + { + foreach (WeixinRequestContent p in ls) + { + if (oldwc.Find(s => s.Id == p.Id) != null) + { + oldwc.Remove(oldwc.Find(s => s.Id == p.Id)); + } + } + if (oldwc != null && oldwc.Count > 0) + { + oldwc.Delete(); + } + } + if (ls != null && ls.Count > 0) + { + foreach (var item in ls) + { + item.RuleId = model.Id; + } + } + ls.Save(); + tip.Message = "修改成功!"; + tip.Status = JsonTip.SUCCESS; + //tip.ReturnUrl = "reload"; + Core.Admin.WriteLogActions("修改公众号关注自动回复;"); + return Json(tip); + } + #endregion + + #region 自定义回复规则列表 + //自定义规则 + [MyAuthorize("viewlist", "wxkeywordreply")] + public IActionResult ReplyRule() + { + return View(); + } + //自定义规则列表 + [MyAuthorize("viewlist", "wxkeywordreply")] + public IActionResult GetReplyRuleList(string keyword, int page = 1, int limit = 20) + { + int numPerPage, currentPage, startRowIndex; + + numPerPage = limit; + currentPage = page; + startRowIndex = (currentPage - 1) * numPerPage; + Expression ex = WeixinRequestRule._.RequestType == (int)WeixinRequestRule.XRequestType.Text; + + if (!string.IsNullOrWhiteSpace(keyword)) + { + if (Utils.IsInt(keyword)) + { + ex &= (WeixinRequestRule._.Id == int.Parse(keyword) | WeixinRequestRule._.Keywords.Contains(keyword)); + } + else + { + ex &= WeixinRequestRule._.Keywords.Contains(keyword); + } + } + + IList list = WeixinRequestRule.FindAll(ex, null, null, startRowIndex, numPerPage); + long totalCount = WeixinRequestRule.FindCount(ex, null, null, startRowIndex, numPerPage); + Admin.WriteLogActions($"查看公众号自定义回复规则({page});"); + return Content(JsonConvert.SerializeObject(new { total = totalCount, rows = list }), "text/plain"); + } + #endregion + + #region 添加自定义规则 + [MyAuthorize("add", "wxkeywordreply")] + public IActionResult AddTextReplyRule() + { + WeixinRequestRule model = new WeixinRequestRule(); + Core.Admin.WriteLogActions("查看添加自定义回复规则;"); + return View(model); + } + + //执行添加操作 + [HttpPost] + [MyAuthorize("add", "wxkeywordreply", "JSON")] + public IActionResult AddTextReplyRule(WeixinRequestRule model) + { + + model.IsDefault = 1; + + int responseType = model.ResponseType; + model.RequestType = (int)WeixinRequestRule.XRequestType.Text;//文本请求 + IList ls = new List(); + if (responseType == 0) //纯文本 + { + string txtContent = Request.Form["txtContent"]; + if (string.IsNullOrEmpty(txtContent)) + { + tip.Message = "文本回复,文本不能为空!"; + return Json(tip); + } + model.ResponseType = (int)WeixinRequestRule.XResponseType.Text;//回复的类型:文本1,图文2,语音3,视频4,第三方接口5 + ls.Add(new WeixinRequestContent { RuleId = model.Id, Content = txtContent.Trim() }); + } + else if (responseType == (int)WeixinRequestRule.XResponseType.Image) //图文 + { + #region 赋值规则图片 + + string[] itemIdArr = Request.Form["item_id"]; + string[] itemTitleArr = Request.Form["item_title"]; + string[] itemContentArr = Request.Form["item_imginfo"]; + string[] itemImgUrlArr = Request.Form["item_imgurl"]; + string[] itemLinkUrlArr = Request.Form["item_linkurl"]; + if (itemIdArr != null && itemTitleArr != null && itemImgUrlArr != null && itemLinkUrlArr != null && itemContentArr != null) + { + if ((itemIdArr.Length == itemTitleArr.Length) && (itemTitleArr.Length == itemImgUrlArr.Length) && (itemImgUrlArr.Length == itemLinkUrlArr.Length)) + { + + for (int i = 0; i < itemIdArr.Length; i++) + { + if (!string.IsNullOrEmpty(itemTitleArr[i])) + { + WeixinRequestContent modelt = new WeixinRequestContent(); + modelt.Id = Utils.StrToInt(itemIdArr[i].Trim(), 0); + modelt.Title = itemTitleArr[i].Trim(); + modelt.Content = itemContentArr[i].Trim(); + modelt.ImgURL = itemImgUrlArr[i].Trim(); + modelt.LinkUrl = itemLinkUrlArr[i].Trim(); + modelt.RuleId = model.Id; + ls.Add(modelt); + } + } + //model.contents = ls; + } + } + #endregion + if (ls == null || ls.Count < 1) + { + tip.Message = "图文列表,图文项目不能为空!"; + return Json(tip); + } + + } + else if (responseType == (int)WeixinRequestRule.XResponseType.Video) //语音 + { + string txtSoundTitle = Request.Form["txtSoundTitle"]; + if (string.IsNullOrEmpty(txtSoundTitle)) + { + tip.Message = "语音回复,语音标题不能为空!"; + return Json(tip); + } + string txtSoundUrl = Request.Form["txtSoundUrl"]; + if (string.IsNullOrEmpty(txtSoundUrl)) + { + tip.Message = "语音回复,语音地址不能为空!"; + return Json(tip); + } + string txtSoundContent = Request.Form["txtSoundContent"]; + + ls.Add(new WeixinRequestContent { RuleId = model.Id, MediaURL = txtSoundUrl.Trim(), Title = txtSoundTitle, Content = txtSoundContent}); + } + else if (responseType == (int)WeixinRequestRule.XResponseType.SingleImage) //单图片 + { + string txtSingleImage = Request.Form["txtSingleImage"]; + if (string.IsNullOrEmpty(txtSingleImage)) + { + tip.Message = "单图片回复,图片地址不能为空!"; + return Json(tip); + } + ls.Add(new WeixinRequestContent { RuleId = model.Id, ImgURL = txtSingleImage.Trim() }); + } + model.Insert(); + IList oldwc = model.ListContent; + if (oldwc != null && oldwc.Count > 0) + { + foreach (WeixinRequestContent p in ls) + { + if (oldwc.Find(s => s.Id == p.Id) != null) + { + oldwc.Remove(oldwc.Find(s => s.Id == p.Id)); + } + } + if (oldwc != null && oldwc.Count > 0) + { + oldwc.Delete(); + } + } + if (ls != null && ls.Count > 0) + { + foreach (var item in ls) + { + item.RuleId = model.Id; + } + } + ls.Save(); + + tip.Message = "添加文本关键字回复规则成功!"; + tip.Status = JsonTip.SUCCESS; + tip.ReturnUrl = "close"; + Core.Admin.WriteLogActions("添加文本关键字回复规则;"); + return Json(tip); + } + #endregion + + #region 修改文本回复详情 + [MyAuthorize("edit", "wxkeywordreply")] + public IActionResult EditTextReplyRule() + { + WeixinRequestRule ruleModel = WeixinRequestRule.Find(WeixinRequestRule._.RequestType == (int)WeixinRequestRule.XRequestType.Text);//获取规则 + if (ruleModel == null) + { + return EchoTipPage("系统找不到本记录!"); + } + switch (ruleModel.ResponseType) + { + case 0://文本 + ViewBag.txtContent = ruleModel.ListContent[0].Content; + break; + case 1://多图 + break; + case 2://语音 + ViewBag.txtSoundTitle = ruleModel.ListContent[0].Title; + ViewBag.txtSoundUrl = ruleModel.ListContent[0].MediaURL; + ViewBag.txtSoundContent = ruleModel.ListContent[0].Content; + break; + case 8://单图 + ViewBag.txtSingleImage = ruleModel.ListContent[0].ImgURL; + break; + } + Core.Admin.WriteLogActions($"查看文本回复规则;"); + return View(ruleModel); + } + [HttpPost] + [MyAuthorize( "edit", "wxkeywordreply", "JSON")] + public IActionResult EditTextReplyRule(WeixinRequestRule entity) + { + WeixinRequestRule model = WeixinRequestRule.Find(WeixinRequestRule._.RequestType == (int)WeixinRequestRule.XRequestType.Text & WeixinRequestRule._.Id == entity.Id);//获取规则 + + if (model == null) + { + tip.Message = "系统找不到本记录"; + return Json(tip); + } + + model.ResponseType = entity.ResponseType; + model.Keywords = entity.Keywords; + model.IsLikeQuery = entity.IsLikeQuery; + model.IsDefault = 1; + int defaultDetailId = int.Parse(Request.Form["hdfTID"]);//默认一条的ID。肯定至少有一条 + int responseType = model.ResponseType; + IList ls = new List(); + if (responseType == 0) //纯文本 + { + string txtContent = Request.Form["txtContent"]; + if (string.IsNullOrEmpty(txtContent)) + { + tip.Message = "文本回复,文本不能为空!"; + return Json(tip); + } + model.ResponseType = (int)WeixinRequestRule.XResponseType.Text;//回复的类型:文本1,图文2,语音3,视频4,第三方接口5 + ls.Add(new WeixinRequestContent { RuleId = model.Id, Content = txtContent.Trim(), Id = defaultDetailId }); + } + else if (responseType == (int)WeixinRequestRule.XResponseType.Image) //图文 + { + #region 赋值规则图片 + + string[] itemIdArr = Request.Form["item_id"]; + string[] itemTitleArr = Request.Form["item_title"]; + string[] itemContentArr = Request.Form["item_imginfo"]; + string[] itemImgUrlArr = Request.Form["item_imgurl"]; + string[] itemLinkUrlArr = Request.Form["item_linkurl"]; + if (itemIdArr != null && itemTitleArr != null && itemImgUrlArr != null && itemLinkUrlArr != null && itemContentArr != null) + { + if ((itemIdArr.Length == itemTitleArr.Length) && (itemTitleArr.Length == itemImgUrlArr.Length) && (itemImgUrlArr.Length == itemLinkUrlArr.Length)) + { + + for (int i = 0; i < itemIdArr.Length; i++) + { + if (!string.IsNullOrEmpty(itemTitleArr[i])) + { + WeixinRequestContent modelt = new WeixinRequestContent(); + modelt.Id = Utils.StrToInt(itemIdArr[i].Trim(), 0); + modelt.Title = itemTitleArr[i].Trim(); + modelt.Content = itemContentArr[i].Trim(); + modelt.ImgURL = itemImgUrlArr[i].Trim(); + modelt.LinkUrl = itemLinkUrlArr[i].Trim(); + modelt.RuleId = model.Id; + ls.Add(modelt); + } + } + //model.contents = ls; + } + } + #endregion + if (ls == null || ls.Count < 1) + { + tip.Message = "图文列表,图文项目不能为空!"; + return Json(tip); + } + + } + else if (responseType == (int)WeixinRequestRule.XResponseType.Video) //语音 + { + string txtSoundTitle = Request.Form["txtSoundTitle"]; + if (string.IsNullOrEmpty(txtSoundTitle)) + { + tip.Message = "语音回复,语音标题不能为空!"; + return Json(tip); + } + string txtSoundUrl = Request.Form["txtSoundUrl"]; + if (string.IsNullOrEmpty(txtSoundUrl)) + { + tip.Message = "语音回复,语音地址不能为空!"; + return Json(tip); + } + string txtSoundContent = Request.Form["txtSoundContent"]; + + ls.Add(new WeixinRequestContent { RuleId = model.Id, MediaURL = txtSoundUrl.Trim(), Title = txtSoundTitle, Id = defaultDetailId, Content = txtSoundContent }); + } + else if (responseType == (int)WeixinRequestRule.XResponseType.SingleImage) //单图片 + { + string txtSingleImage = Request.Form["txtSingleImage"]; + if (string.IsNullOrEmpty(txtSingleImage)) + { + tip.Message = "单图片回复,图片地址不能为空!"; + return Json(tip); + } + ls.Add(new WeixinRequestContent { RuleId = model.Id, ImgURL = txtSingleImage.Trim(), Id = defaultDetailId }); + } + model.Save(); + IList oldwc = model.ListContent; + if (oldwc != null && oldwc.Count > 0) + { + foreach (WeixinRequestContent p in ls) + { + if (oldwc.Find(s => s.Id == p.Id) != null) + { + oldwc.Remove(oldwc.Find(s => s.Id == p.Id)); + } + } + if (oldwc != null && oldwc.Count > 0) + { + oldwc.Delete(); + } + } + if (ls != null && ls.Count > 0) + { + foreach (var item in ls) + { + item.RuleId = model.Id; + } + } + ls.Save(); + + tip.Message = "修改文本自动回复成功!"; + tip.Status = JsonTip.SUCCESS; + tip.ReturnUrl = "close"; + Admin.WriteLogActions("修改文本自动回复成;"); + return Json(tip); + } + #endregion + + #region 删除关键字回复规则 + [HttpPost] + [MyAuthorize("del", "wxkeywordreply", "JSON")] + public IActionResult DelTextReplyRule(int id) + { + WeixinRequestRule model = WeixinRequestRule.Find(WeixinRequestRule._.RequestType == (int)WeixinRequestRule.XRequestType.Text & WeixinRequestRule._.Id == id);//获取规则 + if (model == null) + { + tip.Message = "系统找不到本记录"; + return Json(tip); + } + Admin.WriteLogActions("删除关键字回复规则(id:" + model.Id + ");"); + model.Delete(); + tip.Status = JsonTip.SUCCESS; + tip.Message = "删除规则成功"; + return Json(tip); + } + #endregion + + #region 公众号点击事件回复规则 + //自定义规则 + [MyAuthorize("viewlist", "clickreplyrule")] + public ActionResult ClickReplyRule() + { + return View(); + } + //自定义规则列表 + [MyAuthorize("viewlist", "clickreplyrule")] + public ActionResult GetClickReplyRuleList(string keyword, int page = 1, int limit = 20) + { + int numPerPage, currentPage, startRowIndex; + + numPerPage = limit; + currentPage = page; + startRowIndex = (currentPage - 1) * numPerPage; + Expression ex = WeixinRequestRule._.RequestType == (int)WeixinRequestRule.XRequestType.CustomMenu;//点击自定义菜单 + + if (!string.IsNullOrWhiteSpace(keyword)) + { + if (Utils.IsInt(keyword)) + { + ex &= (WeixinRequestRule._.Id == int.Parse(keyword) | WeixinRequestRule._.Keywords.Contains(keyword)); + } + else + { + ex &= WeixinRequestRule._.Keywords.Contains(keyword); + } + } + IList list = WeixinRequestRule.FindAll(ex, null, null, startRowIndex, numPerPage); + long totalCount = WeixinRequestRule.FindCount(ex, null, null, startRowIndex, numPerPage); + Admin.WriteLogActions($"查看公众号点击事件自定义回复规则({page});"); + return Content(JsonConvert.SerializeObject(new { total = totalCount, rows = list }), "text/plain"); + } + #endregion + + #region 添加自定义规则 + [MyAuthorize( "add", "clickreplyrule")] + public IActionResult AddClickReplyRule() + { + WeixinRequestRule model = new WeixinRequestRule(); + model.RequestType = (int)WeixinRequestRule.XRequestType.CustomMenu;//文本请求 + Core.Admin.WriteLogActions("查看添加点击菜单事件回复规则;"); + return View(model); + } + + //执行添加操作 + [HttpPost] + [MyAuthorize( "add", "clickreplyrule", "JSON")] + public IActionResult AddClickReplyRule(WeixinRequestRule model) + { + model.IsDefault = 1; + + int responseType = model.ResponseType; + model.RequestType = (int)WeixinRequestRule.XRequestType.CustomMenu;//文本请求 + IList ls = new List(); + if (responseType == 0) //纯文本 + { + string txtContent = Request.Form["txtContent"]; + if (string.IsNullOrEmpty(txtContent)) + { + tip.Message = "文本回复,文本不能为空!"; + return Json(tip); + } + model.ResponseType = (int)WeixinRequestRule.XResponseType.Text;//回复的类型:文本1,图文2,语音3,视频4,第三方接口5 + ls.Add(new WeixinRequestContent { RuleId = model.Id, Content = txtContent.Trim() }); + } + else if (responseType == (int)WeixinRequestRule.XResponseType.Image) //图文 + { + #region 赋值规则图片 + + string[] itemIdArr = Request.Form["item_id"]; + string[] itemTitleArr = Request.Form["item_title"]; + string[] itemContentArr = Request.Form["item_imginfo"]; + string[] itemImgUrlArr = Request.Form["item_imgurl"]; + string[] itemLinkUrlArr = Request.Form["item_linkurl"]; + if (itemIdArr != null && itemTitleArr != null && itemImgUrlArr != null && itemLinkUrlArr != null && itemContentArr != null) + { + if ((itemIdArr.Length == itemTitleArr.Length) && (itemTitleArr.Length == itemImgUrlArr.Length) && (itemImgUrlArr.Length == itemLinkUrlArr.Length)) + { + + for (int i = 0; i < itemIdArr.Length; i++) + { + if (!string.IsNullOrEmpty(itemTitleArr[i])) + { + WeixinRequestContent modelt = new WeixinRequestContent(); + modelt.Id = Utils.StrToInt(itemIdArr[i].Trim(), 0); + modelt.Title = itemTitleArr[i].Trim(); + modelt.Content = itemContentArr[i].Trim(); + modelt.ImgURL = itemImgUrlArr[i].Trim(); + modelt.LinkUrl = itemLinkUrlArr[i].Trim(); + modelt.RuleId = model.Id; + ls.Add(modelt); + } + } + //model.contents = ls; + } + } + #endregion + if (ls == null || ls.Count < 1) + { + tip.Message = "图文列表,图文项目不能为空!"; + return Json(tip); + } + + } + else if (responseType == (int)WeixinRequestRule.XResponseType.Video) //语音 + { + string txtSoundTitle = Request.Form["txtSoundTitle"]; + if (string.IsNullOrEmpty(txtSoundTitle)) + { + tip.Message = "语音回复,语音标题不能为空!"; + return Json(tip); + } + string txtSoundUrl = Request.Form["txtSoundUrl"]; + if (string.IsNullOrEmpty(txtSoundUrl)) + { + tip.Message = "语音回复,语音地址不能为空!"; + return Json(tip); + } + string txtSoundContent = Request.Form["txtSoundContent"]; + + ls.Add(new WeixinRequestContent { RuleId = model.Id, MediaURL = txtSoundUrl.Trim(), Title = txtSoundTitle, Content = txtSoundContent }); + } + else if (responseType == (int)WeixinRequestRule.XResponseType.SingleImage) //单图片 + { + string txtSingleImage = Request.Form["txtSingleImage"]; + if (string.IsNullOrEmpty(txtSingleImage)) + { + tip.Message = "单图片回复,图片地址不能为空!"; + return Json(tip); + } + ls.Add(new WeixinRequestContent { RuleId = model.Id, ImgURL = txtSingleImage.Trim() }); + } + model.Insert(); + IList oldwc = model.ListContent; + if (oldwc != null && oldwc.Count > 0) + { + foreach (WeixinRequestContent p in ls) + { + if (oldwc.Find(s => s.Id == p.Id) != null) + { + oldwc.Remove(oldwc.Find(s => s.Id == p.Id)); + } + } + if (oldwc != null && oldwc.Count > 0) + { + oldwc.Delete(); + } + } + if (ls != null && ls.Count > 0) + { + foreach (var item in ls) + { + item.RuleId = model.Id; + } + } + ls.Save(); + + tip.Message = "添加自定义菜单点击事件回复规则成功!"; + tip.Status = JsonTip.SUCCESS; + tip.ReturnUrl = "close"; + Admin.WriteLogActions("添加自定义菜单点击事件回复规则;"); + return Json(tip); + } + #endregion + + #region 修改文点击回复详情 + [MyAuthorize("edit", "clickreplyrule")] + public IActionResult EditClickReplyRule() + { + + WeixinRequestRule ruleModel = WeixinRequestRule.Find(WeixinRequestRule._.RequestType == (int)WeixinRequestRule.XRequestType.CustomMenu);//获取规则 + if (ruleModel == null) + { + return EchoTipPage("系统找不到本记录!"); + } + switch (ruleModel.ResponseType) + { + case 0://文本 + ViewBag.txtContent = ruleModel.ListContent[0].Content; + break; + case 1://多图 + break; + case 2://语音 + ViewBag.txtSoundTitle = ruleModel.ListContent[0].Title; + ViewBag.txtSoundUrl = ruleModel.ListContent[0].MediaURL; + ViewBag.txtSoundContent = ruleModel.ListContent[0].Content; + break; + case 8://单图 + ViewBag.txtSingleImage = ruleModel.ListContent[0].ImgURL; + break; + } + Core.Admin.WriteLogActions($"查看点击菜单事件回复规则;"); + return View(ruleModel); + } + + [HttpPost] + [MyAuthorize( "edit", "clickreplyrule", "JSON")] + public IActionResult EditClickReplyRule(WeixinRequestRule entity) + { + WeixinRequestRule model = WeixinRequestRule.Find(WeixinRequestRule._.RequestType == (int)WeixinRequestRule.XRequestType.CustomMenu & WeixinRequestRule._.Id == entity.Id);//获取规则 + + if (model == null) + { + tip.Message = "系统找不到本记录"; + return Json(tip); + } + + model.ResponseType = entity.ResponseType; + model.Keywords = entity.Keywords; + model.IsDefault = 1; + int defaultDetailId = int.Parse(Request.Form["hdfTID"]);//默认一条的ID。肯定至少有一条 + int responseType = model.ResponseType; + IList ls = new List(); + if (responseType == 0) //纯文本 + { + string txtContent = Request.Form["txtContent"]; + if (string.IsNullOrEmpty(txtContent)) + { + tip.Message = "文本回复,文本不能为空!"; + return Json(tip); + } + model.ResponseType = (int)WeixinRequestRule.XResponseType.Text;//回复的类型:文本1,图文2,语音3,视频4,第三方接口5 + ls.Add(new WeixinRequestContent { RuleId = model.Id, Content = txtContent.Trim(), Id = defaultDetailId }); + } + else if (responseType == (int)WeixinRequestRule.XResponseType.Image) //图文 + { + #region 赋值规则图片 + + string[] itemIdArr = Request.Form["item_id"]; + string[] itemTitleArr = Request.Form["item_title"]; + string[] itemContentArr = Request.Form["item_imginfo"]; + string[] itemImgUrlArr = Request.Form["item_imgurl"]; + string[] itemLinkUrlArr = Request.Form["item_linkurl"]; + if (itemIdArr != null && itemTitleArr != null && itemImgUrlArr != null && itemLinkUrlArr != null && itemContentArr != null) + { + if ((itemIdArr.Length == itemTitleArr.Length) && (itemTitleArr.Length == itemImgUrlArr.Length) && (itemImgUrlArr.Length == itemLinkUrlArr.Length)) + { + + for (int i = 0; i < itemIdArr.Length; i++) + { + if (!string.IsNullOrEmpty(itemTitleArr[i])) + { + WeixinRequestContent modelt = new WeixinRequestContent(); + modelt.Id = Utils.StrToInt(itemIdArr[i].Trim(), 0); + modelt.Title = itemTitleArr[i].Trim(); + modelt.Content = itemContentArr[i].Trim(); + modelt.ImgURL = itemImgUrlArr[i].Trim(); + modelt.LinkUrl = itemLinkUrlArr[i].Trim(); + modelt.RuleId = model.Id; + ls.Add(modelt); + } + } + //model.contents = ls; + } + } + #endregion + if (ls == null || ls.Count < 1) + { + tip.Message = "图文列表,图文项目不能为空!"; + return Json(tip); + } + + } + else if (responseType == (int)WeixinRequestRule.XResponseType.Video) //语音 + { + string txtSoundTitle = Request.Form["txtSoundTitle"]; + if (string.IsNullOrEmpty(txtSoundTitle)) + { + tip.Message = "语音回复,语音标题不能为空!"; + return Json(tip); + } + string txtSoundUrl = Request.Form["txtSoundUrl"]; + if (string.IsNullOrEmpty(txtSoundUrl)) + { + tip.Message = "语音回复,语音地址不能为空!"; + return Json(tip); + } + string txtSoundContent = Request.Form["txtSoundContent"]; + + ls.Add(new WeixinRequestContent { RuleId = model.Id, MediaURL = txtSoundUrl.Trim(), Title = txtSoundTitle, Id = defaultDetailId, Content = txtSoundContent }); + } + else if (responseType == (int)WeixinRequestRule.XResponseType.SingleImage) //单图片 + { + string txtSingleImage = Request.Form["txtSingleImage"]; + if (string.IsNullOrEmpty(txtSingleImage)) + { + tip.Message = "单图片回复,图片地址不能为空!"; + return Json(tip); + } + ls.Add(new WeixinRequestContent { RuleId = model.Id, ImgURL = txtSingleImage.Trim(), Id = defaultDetailId }); + } + model.Save(); + IList oldwc = model.ListContent; + if (oldwc != null && oldwc.Count > 0) + { + foreach (WeixinRequestContent p in ls) + { + if (oldwc.Find(s => s.Id == p.Id) != null) + { + oldwc.Remove(oldwc.Find(s => s.Id == p.Id)); + } + } + if (oldwc != null && oldwc.Count > 0) + { + oldwc.Delete(); + } + } + if (ls != null && ls.Count > 0) + { + foreach (var item in ls) + { + item.RuleId = model.Id; + } + } + ls.Save(); + + tip.Message = "修改点击自定义菜单事件自动回复成功!"; + tip.Status = JsonTip.SUCCESS; + tip.ReturnUrl = "close"; + Admin.WriteLogActions("修改点击自定义菜单事件自动回复;"); + return Json(tip); + } + #endregion + + #region 未找到关键字自动回复 + [HttpGet] + [MyAuthorize("view", "wxnotfindkeywordautoreply")] + public ActionResult NotFindKeywordAutoReply() + { + + WeixinRequestRule ruleModel = WeixinRequestRule.Find(WeixinRequestRule._.RequestType == (int)WeixinRequestRule.XRequestType.NotFindKeyword);//获取规则 + if (ruleModel == null) + { + ruleModel = new WeixinRequestRule(); + ruleModel.RequestType = (int)WeixinRequestRule.XRequestType.NotFindKeyword; + ruleModel.ResponseType = (int)WeixinRequestRule.XResponseType.Text; + ruleModel.RuleName = "未找到关键词自动回复"; + ruleModel.IsDefault = 1; + ruleModel.Insert(); + //增加Response + WeixinRequestContent content = new WeixinRequestContent() + { + RuleId = ruleModel.Id, + Content = "未找到关键词自动回复", + + }; + content.Insert(); + ruleModel = WeixinRequestRule.Find(WeixinRequestRule._.RequestType == (int)WeixinRequestRule.XRequestType.NotFindKeyword);//重新获取规则 + } + switch (ruleModel.ResponseType) + { + case 0://文本 + ViewBag.txtContent = ruleModel.ListContent[0].Content; + break; + case 1://多图 + break; + case 2://语音 + ViewBag.txtSoundTitle = ruleModel.ListContent[0].Title; + ViewBag.txtSoundUrl = ruleModel.ListContent[0].MediaURL; + ViewBag.txtSoundContent = ruleModel.ListContent[0].Content; + break; + case 8://单图 + ViewBag.txtSingleImage = ruleModel.ListContent[0].ImgURL; + break; + } + + Core.Admin.WriteLogActions("查看公众号未找到关键字自动回复;"); + return View(ruleModel); + } + //编辑自动回复规则 + [HttpPost] + [MyAuthorize("edit", "wxnotfindkeywordautoreply", "JSON")] + public IActionResult NotFindKeywordAutoReply(WeixinRequestRule entity) + { + WeixinRequestRule model = WeixinRequestRule.Find(WeixinRequestRule._.RequestType == (int)WeixinRequestRule.XRequestType.NotFindKeyword );//获取规则 + model.ResponseType = entity.ResponseType; + + model.IsDefault = 1; + int defaultDetailId = int.Parse(Request.Form["hdfTID"]);//默认一条的ID。肯定至少有一条 + int responseType = model.ResponseType; + IList ls = new List(); + if (responseType == 0) //纯文本 + { + string txtContent = Request.Form["txtContent"]; + if (string.IsNullOrEmpty(txtContent)) + { + tip.Message = "文本回复,文本不能为空!"; + return Json(tip); + } + model.ResponseType = (int)WeixinRequestRule.XResponseType.Text;//回复的类型:文本1,图文2,语音3,视频4,第三方接口5 + ls.Add(new WeixinRequestContent { RuleId = model.Id, Content = txtContent.Trim(), Id = defaultDetailId }); + } + else if (responseType == (int)WeixinRequestRule.XResponseType.Image) //图文 + { + #region 赋值规则图片 + + string[] itemIdArr = Request.Form["item_id"]; + string[] itemTitleArr = Request.Form["item_title"]; + string[] itemContentArr = Request.Form["item_imginfo"]; + string[] itemImgUrlArr = Request.Form["item_imgurl"]; + string[] itemLinkUrlArr = Request.Form["item_linkurl"]; + if (itemIdArr != null && itemTitleArr != null && itemImgUrlArr != null && itemLinkUrlArr != null && itemContentArr != null) + { + if ((itemIdArr.Length == itemTitleArr.Length) && (itemTitleArr.Length == itemImgUrlArr.Length) && (itemImgUrlArr.Length == itemLinkUrlArr.Length)) + { + + for (int i = 0; i < itemIdArr.Length; i++) + { + if (!string.IsNullOrEmpty(itemTitleArr[i])) + { + WeixinRequestContent modelt = new WeixinRequestContent(); + modelt.Id = Utils.StrToInt(itemIdArr[i].Trim(), 0); + modelt.Title = itemTitleArr[i].Trim(); + modelt.Content = itemContentArr[i].Trim(); + modelt.ImgURL = itemImgUrlArr[i].Trim(); + modelt.LinkUrl = itemLinkUrlArr[i].Trim(); + modelt.RuleId = model.Id; + ls.Add(modelt); + } + } + //model.contents = ls; + } + } + #endregion + if (ls == null || ls.Count < 1) + { + tip.Message = "图文列表,图文项目不能为空!"; + return Json(tip); + } + + } + else if (responseType == (int)WeixinRequestRule.XResponseType.Video) //语音 + { + string txtSoundTitle = Request.Form["txtSoundTitle"]; + if (string.IsNullOrEmpty(txtSoundTitle)) + { + tip.Message = "语音回复,语音标题不能为空!"; + return Json(tip); + } + string txtSoundUrl = Request.Form["txtSoundUrl"]; + if (string.IsNullOrEmpty(txtSoundUrl)) + { + tip.Message = "语音回复,语音地址不能为空!"; + return Json(tip); + } + string txtSoundContent = Request.Form["txtSoundContent"]; + + ls.Add(new WeixinRequestContent { RuleId = model.Id, MediaURL = txtSoundUrl.Trim(), Title = txtSoundTitle, Id = defaultDetailId, Content = txtSoundContent }); + } + else if (responseType == (int)WeixinRequestRule.XResponseType.SingleImage) //单图片 + { + string txtSingleImage = Request.Form["txtSingleImage"]; + if (string.IsNullOrEmpty(txtSingleImage)) + { + tip.Message = "单图片回复,图片地址不能为空!"; + return Json(tip); + } + ls.Add(new WeixinRequestContent { RuleId = model.Id, ImgURL = txtSingleImage.Trim(), Id = defaultDetailId }); + } + model.Save(); + IList oldwc = model.ListContent; + if (oldwc != null && oldwc.Count > 0) + { + foreach (WeixinRequestContent p in ls) + { + if (oldwc.Find(s => s.Id == p.Id) != null) + { + oldwc.Remove(oldwc.Find(s => s.Id == p.Id)); + } + } + if (oldwc != null && oldwc.Count > 0) + { + oldwc.Delete(); + } + } + if (ls != null && ls.Count > 0) + { + foreach (var item in ls) + { + item.RuleId = model.Id; + } + } + ls.Save(); + + tip.Message = "修改成功!"; + tip.Status = JsonTip.SUCCESS; + //tip.ReturnUrl = "reload"; + Admin.WriteLogActions("修改公众号未找到关键字自动回复;"); + return Json(tip); + } + #endregion + + + } +} \ No newline at end of file diff --git a/COMCMS.Web/Areas/AdminCP/Views/Article/AddArticle.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Article/AddArticle.cshtml index 757bb41..65ee885 100644 --- a/COMCMS.Web/Areas/AdminCP/Views/Article/AddArticle.cshtml +++ b/COMCMS.Web/Areas/AdminCP/Views/Article/AddArticle.cshtml @@ -25,7 +25,7 @@
- +
@@ -110,6 +110,9 @@
+ + +
diff --git a/COMCMS.Web/Areas/AdminCP/Views/Article/AddArticleCategory.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Article/AddArticleCategory.cshtml index 98356d8..25e12e9 100644 --- a/COMCMS.Web/Areas/AdminCP/Views/Article/AddArticleCategory.cshtml +++ b/COMCMS.Web/Areas/AdminCP/Views/Article/AddArticleCategory.cshtml @@ -28,7 +28,13 @@
- + +
+
+
+ +
+
@@ -154,4 +160,28 @@ DoPost("addArticleKindForm"); CKEDITOR.replace('KindInfo'); }) + function aoutoTransform() { + var title = $("#KindName").val(); + var filePath = $("#FilePath").val(); + if (!filePath) { + $.ajax({ + type: "POST", + url: "/AdminCP/Server/Hanzi2Pinyin", + data: { name: title}, + dataType: "JSON", + success: function (data) { + if (data.status == "success") { + if (data.message) { + $("#FilePath").val(data.message); + } + } else { + layer.alert(data.message, { icon: 2 }); + } + }, + error: function () { + layer.alert('执行错误,请联系管理员!', { icon: 2 }); + } + }); + } + } diff --git a/COMCMS.Web/Areas/AdminCP/Views/Article/ArticleList.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Article/ArticleList.cshtml index 9b67e96..6d0c26b 100644 --- a/COMCMS.Web/Areas/AdminCP/Views/Article/ArticleList.cshtml +++ b/COMCMS.Web/Areas/AdminCP/Views/Article/ArticleList.cshtml @@ -41,7 +41,15 @@ 新增 } - + + + @* @@ -105,45 +113,45 @@ minimumCountColumns: 2, //最少允许的列数 clickToSelect: true, //是否启用点击选中行 height: 0, //行高,如果没有设置height属性,表格自动根据记录条数觉得表格高度 - uniqueId: "Id", //每一行的唯一标识,一般为主键列 + uniqueId: "id", //每一行的唯一标识,一般为主键列 showToggle: true, //是否显示详细视图和列表视图的切换按钮 cardView: false, //是否显示详细视图 detailView: false, //是否显示父子表 columns: [{ checkbox: true }, { - field: 'Id', + field: 'id', title: 'ID' }, { - field: 'ArticleKind.KindName', + field: 'articleKind.kindName', title: '所属栏目' }, { - field: 'Title', + field: 'title', title: '文章标题' }, { - field: 'Sequence', + field: 'sequence', title: '排序' }, { - field: 'AddTime', + field: 'addTime', title: '添加时间' }, { - field: 'IsNew', + field: 'isNew', title: '最新', align: 'center', formatter: 'newFormatter' }, { - field: 'IsRecommend', + field: 'isRecommend', title: '推荐', align: 'center', formatter: 'recommendFormatter' }, { - field: 'IsHide', + field: 'isHide', title: '隐藏', align: 'center', formatter: 'hideFormatter' }, { - field: 'Id', + field: 'id', title: '操作', formatter: 'actionFormatter' } @@ -205,6 +213,92 @@ return oInit; }; + function doBatchHide() { + var list = $('#tb_departments').bootstrapTable('getAllSelections'); + var ids = []; + if (!list || list.length <1) { + layer.alert("请至少选择一篇文章!", { icon: 2 }); + return false; + } + list.map(function (item, index) { + if (item.id) { + ids.push(item.id); + } + }) + //alert(JSON.stringify(ids)); + //执行操作 + var loading = layer.load(0, { + shade: [0.2, '#000'] //0.1透明度的背景 + }); + $.ajax({ + type: "POST", + url: "/AdminCP/Article/DoBatchHideArticle", + data: { ids: JSON.stringify(ids)}, + dataType: "JSON", + success: function (data) { + if (data.status == "success") { + layer.close(loading); + layer.msg(data.message, { + time: 1000 //2秒关闭(如果不配置,默认是3秒) + }, function () { + doSearch(); + }); + } else { + layer.close(loading); + layer.alert(data.message, { icon: 2 }); + } + }, + error: function () { + layer.close(loading); + layer.alert('执行错误,请联系管理员!', { icon: 2 }); + } + }); + return false; + } + + function doBatchShow() { + var list = $('#tb_departments').bootstrapTable('getAllSelections'); + var ids = []; + if (!list || list.length <1) { + //alert('请至少选择一行!'); + layer.alert("请至少选择一篇文章!", { icon: 2 }); + return false; + } + list.map(function (item, index) { + if (item.id) { + ids.push(item.id); + } + }) + //alert(JSON.stringify(ids)); + //执行操作 + var loading = layer.load(0, { + shade: [0.2, '#000'] //0.1透明度的背景 + }); + $.ajax({ + type: "POST", + url: "/AdminCP/Article/DoBatchShowArticle", + data: { ids: JSON.stringify(ids)}, + dataType: "JSON", + success: function (data) { + if (data.status == "success") { + layer.close(loading); + layer.msg(data.message, { + time: 1000 //2秒关闭(如果不配置,默认是3秒) + }, function () { + doSearch(); + }); + } else { + layer.close(loading); + layer.alert(data.message, { icon: 2 }); + } + }, + error: function () { + layer.close(loading); + layer.alert('执行错误,请联系管理员!', { icon: 2 }); + } + }); + return false; + }
diff --git a/COMCMS.Web/Areas/AdminCP/Views/Article/EditArticle.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Article/EditArticle.cshtml index 61a7a4c..8b1632a 100644 --- a/COMCMS.Web/Areas/AdminCP/Views/Article/EditArticle.cshtml +++ b/COMCMS.Web/Areas/AdminCP/Views/Article/EditArticle.cshtml @@ -109,6 +109,9 @@
+ + +
diff --git a/COMCMS.Web/Areas/AdminCP/Views/Article/EditArticleCategory.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Article/EditArticleCategory.cshtml index bc8c428..fff93ca 100644 --- a/COMCMS.Web/Areas/AdminCP/Views/Article/EditArticleCategory.cshtml +++ b/COMCMS.Web/Areas/AdminCP/Views/Article/EditArticleCategory.cshtml @@ -28,7 +28,13 @@
- + +
+
+
+ +
+
@@ -37,6 +43,7 @@
+
@@ -157,5 +164,29 @@ $(".upload-img").InitUploader({ filesize: "10240", sendurl: "/AdminCP/Upload/DoWebuploaderImage", swf: "/js/webuploader/uploader.swf", filetypes: "gif,jpg,png,bmp", notwater: true }); DoPost("editArticleKindForm"); CKEDITOR.replace('KindInfo'); - }) + }); + function aoutoTransform() { + var title = $("#KindName").val(); + var filePath = $("#FilePath").val(); + if (!filePath) { + $.ajax({ + type: "POST", + url: "/AdminCP/Server/Hanzi2Pinyin", + data: { name: title}, + dataType: "JSON", + success: function (data) { + if (data.status == "success") { + if (data.message) { + $("#FilePath").val(data.message); + } + } else { + layer.alert(data.message, { icon: 2 }); + } + }, + error: function () { + layer.alert('执行错误,请联系管理员!', { icon: 2 }); + } + }); + } + } \ No newline at end of file diff --git a/COMCMS.Web/Areas/AdminCP/Views/Article/MoveArticle.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Article/MoveArticle.cshtml new file mode 100644 index 0000000..11aae9d --- /dev/null +++ b/COMCMS.Web/Areas/AdminCP/Views/Article/MoveArticle.cshtml @@ -0,0 +1,58 @@ +@{ + ViewBag.title = "批量迁移文章"; +} +
+
+
+
@ViewBag.Title
+
+
+
+
+ @using (Html.BeginForm(null, null, FormMethod.Post, new { id = "moveArticleForm", @class = "form-horizontal m-t" })) + { +
+ 注意:请务必确认迁移栏目文章,本操作不可逆,请慎重操作! +
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+
+
+ + +
+
+ } +
+
+ + +
+ \ No newline at end of file diff --git a/COMCMS.Web/Areas/AdminCP/Views/Index/Index.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Index/Index.cshtml index ff8c9ee..998eb8b 100644 --- a/COMCMS.Web/Areas/AdminCP/Views/Index/Index.cshtml +++ b/COMCMS.Web/Areas/AdminCP/Views/Index/Index.cshtml @@ -113,11 +113,11 @@
-
- -
- +
+
+ +
+ +
-
-
- -
- +
+ +
+ +
-
-
- -
- +
+ +
+ +
-
-
- -
- +
+ +
+ +
-
-
- -
- +
+ +
+ +
-
-
- -
- +
+ +
+ +
diff --git a/COMCMS.Web/Areas/AdminCP/Views/Member/Admins.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Member/Admins.cshtml index 0b1b86c..564feb4 100644 --- a/COMCMS.Web/Areas/AdminCP/Views/Member/Admins.cshtml +++ b/COMCMS.Web/Areas/AdminCP/Views/Member/Admins.cshtml @@ -135,7 +135,7 @@ limit: params.limit, //页面大小 page: (params.offset / params.limit) + 1, //页码 roleid: $("#roleid").val(), - departmentname: $("#keyword").val() + keyword: $("#keyword").val() }; return temp; }; diff --git a/COMCMS.Web/Areas/AdminCP/Views/Member/MemberRole.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Member/MemberRole.cshtml index 6bfbf2a..7996d9b 100644 --- a/COMCMS.Web/Areas/AdminCP/Views/Member/MemberRole.cshtml +++ b/COMCMS.Web/Areas/AdminCP/Views/Member/MemberRole.cshtml @@ -8,11 +8,11 @@
@ViewBag.Title
- @*
- -
*@ +
+ +
+
+
+
+ +
+
+
+ + + + +
+
+ } +
+
+ + +
+ \ No newline at end of file diff --git a/COMCMS.Web/Areas/AdminCP/Views/Weixin/AddTextReplyRule.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Weixin/AddTextReplyRule.cshtml new file mode 100644 index 0000000..f2ff029 --- /dev/null +++ b/COMCMS.Web/Areas/AdminCP/Views/Weixin/AddTextReplyRule.cshtml @@ -0,0 +1,191 @@ +@model WeixinRequestRule +@{ + ViewBag.Title = "添加公众号文本关键字回复详情"; +} + +
+
+
+
@ViewBag.Title
+
+
+
+
+ @using (Html.BeginForm(null, null, FormMethod.Post, new { id = "addTextReplyForm", @class = "form-horizontal m-t" })) + { +
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+
+
+ +
+ +
+ @if (Model.ListContent != null && Model.ListContent.Count > 0) + { + + } + else + { + + } +
+
+ +
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+
+ + + + +
+
+
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + +
图片(必填)链接地址(必填)图片标题图片说明操作
+ + +
+
+
+
+ +
+
+ +
+
+ + + + +
+
+
+
+ +
+
+
+ + + + +
+
+ } +
+
+ +
+ \ No newline at end of file diff --git a/COMCMS.Web/Areas/AdminCP/Views/Weixin/ClickReplyRule.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Weixin/ClickReplyRule.cshtml new file mode 100644 index 0000000..86a2214 --- /dev/null +++ b/COMCMS.Web/Areas/AdminCP/Views/Weixin/ClickReplyRule.cshtml @@ -0,0 +1,170 @@ + +@{ + ViewBag.Title = "微信公众号点击事件回复规则管理"; +} +
+
+
+
@ViewBag.Title
+
+
+
+
+
+
筛选条件
+
+
+
+ + + +
+
+
+
+
+ + +
+
+ + +
+
+ + +
diff --git a/COMCMS.Web/Areas/AdminCP/Views/Weixin/EditClickReplyRule.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Weixin/EditClickReplyRule.cshtml new file mode 100644 index 0000000..55e6177 --- /dev/null +++ b/COMCMS.Web/Areas/AdminCP/Views/Weixin/EditClickReplyRule.cshtml @@ -0,0 +1,225 @@ +@model WeixinRequestRule +@{ + ViewBag.Title = "修改公众号点击事件回复详情"; +} + +
+
+
+
@ViewBag.Title
+
+
+
+
+
+ KEY,为点击事件KEY,配置好后,自定义菜单选择 CLICK事件,然后key填入此key即可。 +
+ @using (Html.BeginForm(null, null, FormMethod.Post, new { id = "editClickReplyForm", @class = "form-horizontal m-t" })) + { +
+ +
+ +
+
+ +
+ +
+ +
+
+
+
+ +
+ +
+ @if (Model.ListContent != null && Model.ListContent.Count > 0) + { + + } + else + { + + } +
+
+ +
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+
+ + + + +
+
+
+
+ +
+
+
+ + + + + + + + + + + + @if (Model.ResponseType == (int)WeixinRequestRule.XResponseType.Image) + { + if (Model.ListContent.Count > 0) + { + for (int i = 0; i < Model.ListContent.Count; i++) + { + + + + + + + + } + } + else + { + + + + + + + + } + } + else + { + + + + + + + + } + + +
图片(必填)链接地址(必填)图片标题图片说明操作
+ @if (i == 0) + { + + } + else + { + + } + +
+ + +
+ + +
+
+
+
+ +
+
+ +
+
+ + + + +
+
+
+
+ +
+
+
+ + + + +
+
+ } +
+
+ + +
+ \ No newline at end of file diff --git a/COMCMS.Web/Areas/AdminCP/Views/Weixin/EditTextReplyRule.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Weixin/EditTextReplyRule.cshtml new file mode 100644 index 0000000..0133b77 --- /dev/null +++ b/COMCMS.Web/Areas/AdminCP/Views/Weixin/EditTextReplyRule.cshtml @@ -0,0 +1,229 @@ +@model WeixinRequestRule +@{ + ViewBag.Title = "修改公众号文本关键字回复详情"; +} + +
+
+
+
@ViewBag.Title
+
+
+
+
+ @using (Html.BeginForm(null, null, FormMethod.Post, new { id = "editTextReplyForm", @class = "form-horizontal m-t" })) + { +
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+
+
+ +
+ +
+ @if (Model.ListContent != null && Model.ListContent.Count > 0) + { + + } + else + { + + } +
+
+ +
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+
+ + + + +
+
+
+
+ +
+
+
+ + + + + + + + + + + + @if (Model.ResponseType == (int)WeixinRequestRule.XResponseType.Image) + { + if (Model.ListContent.Count > 0) + { + for (int i = 0; i < Model.ListContent.Count; i++) + { + + + + + + + + } + } + else + { + + + + + + + + } + } + else + { + + + + + + + + } + + +
图片(必填)链接地址(必填)图片标题图片说明操作
+ @if (i == 0) + { + + } + else + { + + } + +
+ + +
+ + +
+
+
+
+ +
+
+ +
+
+ + + + +
+
+
+
+ +
+
+
+ + + + +
+
+ } +
+
+
+ \ No newline at end of file diff --git a/COMCMS.Web/Areas/AdminCP/Views/Weixin/Menu.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Weixin/Menu.cshtml new file mode 100644 index 0000000..1e8ea34 --- /dev/null +++ b/COMCMS.Web/Areas/AdminCP/Views/Weixin/Menu.cshtml @@ -0,0 +1,194 @@ +@model Senparc.Weixin.MP.Entities.GetMenuResult +@{ + ViewBag.Title = "自定义菜单管理"; +} + +
+
+
+
@ViewBag.Title
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + +
#第一列第二列第三列
一级菜单 + + + + + + +
二级菜单NO.{{item + 1}} + + + + + + + +
+
+
+ + +
+ \ No newline at end of file diff --git a/COMCMS.Web/Areas/AdminCP/Views/Weixin/NotFindKeywordAutoReply.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Weixin/NotFindKeywordAutoReply.cshtml new file mode 100644 index 0000000..30a29d0 --- /dev/null +++ b/COMCMS.Web/Areas/AdminCP/Views/Weixin/NotFindKeywordAutoReply.cshtml @@ -0,0 +1,221 @@ +@model WeixinRequestRule +@{ + ViewBag.Title = "编辑/查看公众号未找到关键字自动回复详情"; +} + +
+
+
+
@ViewBag.Title
+
+
+
+
+ @using (Html.BeginForm(null, null, FormMethod.Post, new { id = "editSubscribeReplyForm", @class = "form-horizontal m-t" })) + { +
+ +
+ +
+
+
+
+ +
+ +
+ @if (Model.ListContent != null && Model.ListContent.Count > 0) + { + + } + else + { + + } +
+
+ +
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+
+ + + + +
+
+
+
+ +
+
+
+ + + + + + + + + + + + @if (Model.ResponseType == (int)WeixinRequestRule.XResponseType.Image) + { + if (Model.ListContent.Count > 0) + { + for (int i = 0; i < Model.ListContent.Count; i++) + { + + + + + + + + } + } + else + { + + + + + + + + } + } + else + { + + + + + + + + } + + +
图片(必填)链接地址(必填)图片标题图片说明操作
+ @if (i == 0) + { + + } + else + { + + } + +
+ + +
+ + + + +
+
+
+
+ +
+
+ +
+
+ + + + +
+
+
+
+ +
+
+
+ + + + +
+
+ } +
+
+ + +
+ + \ No newline at end of file diff --git a/COMCMS.Web/Areas/AdminCP/Views/Weixin/ReplyRule.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Weixin/ReplyRule.cshtml new file mode 100644 index 0000000..a47e206 --- /dev/null +++ b/COMCMS.Web/Areas/AdminCP/Views/Weixin/ReplyRule.cshtml @@ -0,0 +1,175 @@ + +@{ + ViewBag.Title = "微信公众号关键字回复规则管理"; +} +
+
+
+
@ViewBag.Title
+
+
+
+
+
+
筛选条件
+
+
+
+ + + +
+
+
+
+
+ +
+
+ + +
+
+ + +
\ No newline at end of file diff --git a/COMCMS.Web/Areas/AdminCP/Views/Weixin/SubscribeReply.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Weixin/SubscribeReply.cshtml new file mode 100644 index 0000000..b57181e --- /dev/null +++ b/COMCMS.Web/Areas/AdminCP/Views/Weixin/SubscribeReply.cshtml @@ -0,0 +1,220 @@ +@model WeixinRequestRule +@{ + ViewBag.Title = "编辑/查看公众号关注自动回复详情"; +} + +
+
+
+
@ViewBag.Title
+
+
+
+
+ @using (Html.BeginForm(null, null, FormMethod.Post, new { id = "editSubscribeReplyForm", @class = "form-horizontal m-t" })) + { +
+ +
+ +
+
+
+
+ +
+ +
+ @if (Model.ListContent != null && Model.ListContent.Count > 0) + { + + } + else + { + + } +
+
+ +
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+
+ + + + +
+
+
+
+ +
+
+
+ + + + + + + + + + + + @if (Model.ResponseType == (int)WeixinRequestRule.XResponseType.Image) + { + if (Model.ListContent.Count > 0) + { + for (int i = 0; i < Model.ListContent.Count; i++) + { + + + + + + + + } + } + else + { + + + + + + + + } + } + else + { + + + + + + + + } + + +
图片(必填)链接地址(必填)图片标题图片说明操作
+ @if (i == 0) + { + + } + else + { + + } + +
+ + +
+ + + + +
+
+
+
+ +
+
+ +
+
+ + + + +
+
+
+
+ +
+
+
+ + + + +
+
+ } +
+
+ + +
+ diff --git a/COMCMS.Web/COMCMS.Web.csproj b/COMCMS.Web/COMCMS.Web.csproj index e136e6e..4787130 100644 --- a/COMCMS.Web/COMCMS.Web.csproj +++ b/COMCMS.Web/COMCMS.Web.csproj @@ -1,26 +1,29 @@  - netcoreapp2.1 + netcoreapp3.1 - - - - - - - - - - - - + + + + + + + + + + + + + + + @@ -32,6 +35,7 @@ + diff --git a/COMCMS.Web/Common/AdminUtils.cs b/COMCMS.Web/Common/AdminUtils.cs index 5fc391b..07704cc 100644 --- a/COMCMS.Web/Common/AdminUtils.cs +++ b/COMCMS.Web/Common/AdminUtils.cs @@ -54,5 +54,48 @@ namespace COMCMS.Web.Common } #endregion + #region 判断文章栏目或者商品栏目,栏目路径是否已经存在 + /// + /// 判断路径名称是否合法 + /// + /// + /// id,大于0是修改 + /// 类型,0文章,1商品 + /// + public static bool CheckFilePathIsOK(string pathname, int kid, int typeid) + { + bool flag = true; + + if (string.IsNullOrEmpty(pathname)) + { + return false; + } + if(typeid ==0)//文章 + { + if (ArticleCategory.FindCount(ArticleCategory._.FilePath == pathname & ArticleCategory._.Id != kid, null, null, 0, 0) > 0) + { + return false; + } + if (Category.FindCount(Category._.FilePath == pathname, null, null, 0, 0) > 0) + { + return false; + } + } + else if(typeid == 1) + { + if (ArticleCategory.FindCount(ArticleCategory._.FilePath == pathname , null, null, 0, 0) > 0) + { + return false; + } + if (Category.FindCount(Category._.FilePath == pathname & Category._.Id != kid, null, null, 0, 0) > 0) + { + return false; + } + } + + return flag; + } + #endregion + } } diff --git a/COMCMS.Web/Common/HomeBaseController.cs b/COMCMS.Web/Common/HomeBaseController.cs index 97a5af8..cc864ce 100644 --- a/COMCMS.Web/Common/HomeBaseController.cs +++ b/COMCMS.Web/Common/HomeBaseController.cs @@ -29,7 +29,7 @@ namespace COMCMS.Web.Common public IActionResult AlertAndGoBack(string str) { if (!string.IsNullOrWhiteSpace(str)) str = str.Replace("'", "\\'"); - return Content($""); + return Content($"", "text/html", System.Text.Encoding.UTF8); } /// /// Alert提示并跳转到指定URL @@ -39,7 +39,7 @@ namespace COMCMS.Web.Common public IActionResult AlertAndRedirect(string str, string url) { if (!string.IsNullOrWhiteSpace(str)) str = str.Replace("'", "\\'"); - return Content($""); + return Content($"", "text/html", System.Text.Encoding.UTF8); } #region MyRegion diff --git a/COMCMS.Web/Common/HttpGlobalExceptionFilter.cs b/COMCMS.Web/Common/HttpGlobalExceptionFilter.cs index b32fff8..25944c5 100644 --- a/COMCMS.Web/Common/HttpGlobalExceptionFilter.cs +++ b/COMCMS.Web/Common/HttpGlobalExceptionFilter.cs @@ -12,8 +12,8 @@ namespace COMCMS.Web.Common { public class HttpGlobalExceptionFilter : IExceptionFilter { - readonly IHostingEnvironment _env; - public HttpGlobalExceptionFilter(IHostingEnvironment env) + readonly IWebHostEnvironment _env; + public HttpGlobalExceptionFilter(IWebHostEnvironment env) { _env = env; } diff --git a/COMCMS.Web/Common/MenuRegister.cs b/COMCMS.Web/Common/MenuRegister.cs index efb631e..bf7efca 100644 --- a/COMCMS.Web/Common/MenuRegister.cs +++ b/COMCMS.Web/Common/MenuRegister.cs @@ -139,7 +139,7 @@ namespace COMCMS.Web.Common public static void Register() { - Task.Run(() => { StartRegister(); }).LogException(); + Task.Run(() => { StartRegister(); }); } } } diff --git a/COMCMS.Web/Common/ViewsHelper.cs b/COMCMS.Web/Common/ViewsHelper.cs new file mode 100644 index 0000000..427584e --- /dev/null +++ b/COMCMS.Web/Common/ViewsHelper.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using COMCMS.Core; +using COMCMS.Common; +using XCode; + + +namespace COMCMS.Web.Common +{ + /// + /// 识图方法 + /// + public class ViewsHelper + { + #region 获取分类链接 + /// + /// 文章分类 + /// + /// + /// + public static string EchoURL(ArticleCategory model) + { + if (model == null) + return ""; + if (!string.IsNullOrEmpty(model.FilePath)) + return model.FilePath + "/index.html"; + else + return $"/article/index/{model.Id}"; + } + /// + /// 商品分类 + /// + /// + /// + public static string EchoURL(Category model) + { + if (model == null) + return ""; + if (!string.IsNullOrEmpty(model.FilePath)) + return model.FilePath + "/index.html"; + else + return $"/product/index/{model.Id}"; + } + /// + /// + /// + /// + /// + /// + public static string EchoURL(Utils.CMSType ctype,int id) + { + string url = "/"; + switch (ctype) + { + case Utils.CMSType.ArticleCategory: + ArticleCategory ac = ArticleCategory.FindById(id); + url = EchoURL(ac); + break; + case Utils.CMSType.ProductCategory: + Category pc = Category.FindById(id); + url = EchoURL(pc); + break; + default: + url= "/"; + break; + } + + return url; + } + #endregion + + } +} diff --git a/COMCMS.Web/Configuration/JsonOptionsConfig.cs b/COMCMS.Web/Configuration/JsonOptionsConfig.cs new file mode 100644 index 0000000..5b14718 --- /dev/null +++ b/COMCMS.Web/Configuration/JsonOptionsConfig.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; +using Newtonsoft.Json.Serialization; +using XCode; + +namespace COMCMS.Web.Configuration +{ + public class JsonOptionsConfig + { + public static void ConfigJsonOptions(MvcNewtonsoftJsonOptions options) + { + var settings = options.SerializerSettings; + //日期类型默认格式化处理 + // //setting.DateFormatHandling = DateFormatHandling.MicrosoftDateFormat; + settings.DateFormatString = "yyyy-MM-dd HH:mm:ss"; + + //// 空值处理 + //setting.NullValueHandling = NullValueHandling.Ignore; + + // 最大序列化深度,包括请求传参的序列化深度,不可设置太小了 + settings.MaxDepth = 5; + + // 忽略循环引用 + settings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; + + // 全局设置要排除的字段 + settings.ContractResolver = new LimitPropsContractResolver(new[] { "password", "extends" }, false); + } + } + + /// + /// 限制某些属性输出或排除,设置为保留时,只输出保留属性,其他属性全部忽略。 + /// 设置为排除,只排除设置的属性 + /// + public class LimitPropsContractResolver : CamelCasePropertyNamesContractResolver// DefaultContractResolver + { + private readonly string[] _props = null; + + private readonly bool _retain; + + /// + /// + /// 构造函数 + /// + /// 传入的属性数组 + /// true:表示props是需要保留的字段 false:表示props是要排除的字段 + public LimitPropsContractResolver(string[] props, bool retain = false) + { + //指定要序列化属性的清单 + this._props = props; + + this._retain = retain; + } + + protected override IList CreateProperties(Type type, MemberSerialization memberSerialization) + { + var list = base.CreateProperties(type, memberSerialization); + + // 非实体类型直接返回 + if (!typeof(EntityBase).IsAssignableFrom(type)) + { + return list; + } + + //只保留清单有列出的属性 + list = list.Where(p => + { + var has = _props.Any(a => a.Equals(p.PropertyName, StringComparison.OrdinalIgnoreCase)); + if (_retain) + { + return has; + } + + return !has; + }).ToList(); + return list; + } + } +} diff --git a/COMCMS.Web/Controllers/ArticleController.cs b/COMCMS.Web/Controllers/ArticleController.cs index ee6b1d0..fab86f7 100644 --- a/COMCMS.Web/Controllers/ArticleController.cs +++ b/COMCMS.Web/Controllers/ArticleController.cs @@ -19,6 +19,7 @@ namespace COMCMS.Web.Controllers public IActionResult Index(int id = 0, int page = 1) { ArticleCategory model = ArticleCategory.FindById(id); + if (model == null) { return AlertAndGoBack("系统找不到本记录"); @@ -88,16 +89,13 @@ namespace COMCMS.Web.Controllers } ViewBag.cfg = cfg; - string templatesname = "";//模板名称 + string templatesname = "Index.cshtml";//模板名称 if (!string.IsNullOrEmpty(model.TemplateFile)) { - templatesname = model.TemplateFile.Replace(".cshtml", "").Replace(".aspx", ""); - return View(templatesname, model); - } - else - { - return View(model); + templatesname = model.TemplateFile; + //return Content(templatesname); } + return View("~/Views/Article/" + templatesname, model); //固定死就是这个 } #endregion diff --git a/COMCMS.Web/Controllers/HomeController.cs b/COMCMS.Web/Controllers/HomeController.cs index 6a236db..48a6e4e 100644 --- a/COMCMS.Web/Controllers/HomeController.cs +++ b/COMCMS.Web/Controllers/HomeController.cs @@ -26,7 +26,7 @@ namespace COMCMS.Web.Controllers { ViewBag.cfg = cfg; ViewBag.about = Article.FindById(1);//关于我们 - return View(); + return View("~/Views/Home/Index.cshtml"); } #endregion @@ -46,5 +46,67 @@ namespace COMCMS.Web.Controllers return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); } + #region 测试 + //[Route("c/{*path}/index2.html")] + //public IActionResult Test(string path = "") + //{ + // string tel = "13332835377"; + // return Content(tel.Substring(tel.Length - 5) + ";path:" + path); + //} + //[Route("{path1:regex([[a-zA-Z0-9-]])}/{path2:regex([[a-zA-Z0-9-]])}/index.html")] + //public IActionResult Test2(string path1 = "", string path2 = "") + //{ + // ArticleController ac = new ArticleController(); + // return ac.Index(1); + // //return Content(";ath1:" + path1+";path2:"+path2); + //} + #endregion + + #region 测试拼音 + public IActionResult Test3() + { + var mac = Utils.GetMacs().ToList(); + string re = ""; + foreach (var item in mac) + { + if (string.IsNullOrEmpty(re)) + re = item.ToHex(); + else + re += "-" + item.ToHex(); + } + return Content(re); + } + #endregion + + #region 系统文章栏目、商品栏目路由 + /// + /// 一级路径栏目 + /// + /// + /// + [Route("{path:regex([[a-zA-Z0-9-]])}/index.html")] + [Route("{path:regex([[a-zA-Z0-9-]])}/index-{page:int}.html")] + [Route("{path:regex([[a-zA-Z0-9-]])}/")] + public IActionResult ShowCategory(string path,int page=1) + { + //先判断文章栏目 + ArticleCategory articleCategory = ArticleCategory.FindByFilePath("/" + path); + if(articleCategory != null) + { + //return Content(articleCategory.Id.ToString()); + ArticleController ac = new ArticleController(); + return ac.Index(articleCategory.Id); + } + //再判断商品 + Category category = Category.FindByFilePath("/" + path); + if(category != null) + { + ProductController pc = new ProductController(); + return pc.Index(category.Id,page); + } + return EchoTip("系统找不到本栏目!"+"/"+path); + } + #endregion + } } diff --git a/COMCMS.Web/Controllers/WeixinController.cs b/COMCMS.Web/Controllers/WeixinController.cs new file mode 100644 index 0000000..a57ac04 --- /dev/null +++ b/COMCMS.Web/Controllers/WeixinController.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Senparc.Weixin.MP.Entities.Request; +using COMCMS.Web.Common; +using Senparc.Weixin.MP; +using NewLife.Log; +using COMCMS.Common; +using Senparc.CO2NET.HttpUtility; +using System.Threading; +using COMCMS.API.Weixin.CustomMessageHandler; +using Senparc.Weixin; +using Senparc.NeuChar.MessageHandlers; +using Senparc.Weixin.MP.MvcExtension; + +namespace COMCMS.Web.Controllers +{ + public class WeixinController : HomeBaseController + { + [HttpGet] + [ActionName("Index")] + public Task Get(string signature, string timestamp, string nonce, string echostr) + { + string token = cfg.Token; + + return Task.Factory.StartNew(() => + { + if (CheckSignature.Check(signature, timestamp, nonce, token)) + { + return echostr; //返回随机字符串则表示验证通过 + } + else + { + return "failed:" + signature + "," + Senparc.Weixin.MP.CheckSignature.GetSignature(timestamp, nonce, token) + "。" + + "如果你在浏览器中看到这句话,说明此地址可以被作为微信公众账号后台的Url,请注意保持Token一致。"; + } + }).ContinueWith(task => Content(task.Result)); + } + + + #region 处理微信接口 消息,事件等 + [HttpPost] + [ActionName("Index")] + public async Task Post(PostModel postModel) + { + string token = cfg.Token; + if (!CheckSignature.Check(postModel.Signature, postModel.Timestamp, postModel.Nonce, token)) + { + return Content("参数错误!"); + } + var cancellationToken = new CancellationToken();//给异步方法使用 + var messageHandler = new CustomMessageHandler(Request.GetRequestMemoryStream(), postModel, 10); + #region 设置消息去重 + + /* 如果需要添加消息去重功能,只需打开OmitRepeatedMessage功能,SDK会自动处理。 + * 收到重复消息通常是因为微信服务器没有及时收到响应,会持续发送2-5条不等的相同内容的RequestMessage*/ + messageHandler.OmitRepeatedMessage = true;//默认已经开启,此处仅作为演示,也可以设置为false在本次请求中停用此功能 + + messageHandler.DefaultMessageHandlerAsyncEvent = DefaultMessageHandlerAsyncEvent.SelfSynicMethod; + + #endregion + await messageHandler.ExecuteAsync(cancellationToken); //执行微信处理过程(关键) + + string content = messageHandler.TextResponseMessage.Replace("\r\n", "\n"); + + return Content(content, "text/xml"); + //return new FixWeixinBugWeixinResult(messageHandler); + + } + #endregion + + } +} \ No newline at end of file diff --git a/COMCMS.Web/Controllers/api/ArticleController.cs b/COMCMS.Web/Controllers/api/ArticleController.cs index 3f4c115..48be6e8 100644 --- a/COMCMS.Web/Controllers/api/ArticleController.cs +++ b/COMCMS.Web/Controllers/api/ArticleController.cs @@ -11,7 +11,6 @@ using XCode; using System.Web; using COMCMS.Web.Filter; using NewLife.Log; -using static COMCMS.Web.Models.APIModels; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Senparc.Weixin.WxOpen; @@ -30,7 +29,7 @@ namespace COMCMS.Web.Controllers.api /// [HttpGet] [CheckFilter] - public object GetArticleList(int kid, int pagesize = 10, int page = 1, string random = "", string timeStamp = "", string signature = "") + public object GetArticleList(int kid, int pagesize = 10, int page = 1) { var where = Article._.IsHide != 1; if (kid > 0) @@ -83,7 +82,7 @@ namespace COMCMS.Web.Controllers.api /// [HttpGet] [CheckFilter] - public object GetArticleListWidthSub(int kid, int pagesize = 10, int page = 1, string key = "", string random = "", string timeStamp = "", string signature = "") + public object GetArticleListWidthSub(int kid, int pagesize = 10, int page = 1, string key = "") { var where = Article._.IsHide != 1; @@ -154,7 +153,7 @@ namespace COMCMS.Web.Controllers.api /// [HttpGet] [CheckFilter] - public object GetArticleDetail(int id, string random = "", string timeStamp = "", string signature = "") + public object GetArticleDetail(int id) { //获取商品 Article entity = Article.FindById(id); @@ -173,7 +172,7 @@ namespace COMCMS.Web.Controllers.api #region 获取文章栏目详情,并带下一级栏目 [HttpGet] [CheckFilter] - public object GetArticleCategory(int id, string random = "", string timeStamp = "", string signature = "") + public object GetArticleCategory(int id) { ArticleCategory entity = ArticleCategory.FindById(id); if (entity == null) diff --git a/COMCMS.Web/Controllers/api/IndexController.cs b/COMCMS.Web/Controllers/api/IndexController.cs index 2b65044..903de8e 100644 --- a/COMCMS.Web/Controllers/api/IndexController.cs +++ b/COMCMS.Web/Controllers/api/IndexController.cs @@ -20,6 +20,7 @@ namespace COMCMS.Web.Controllers.api { // GET: api/ [HttpGet] + [CheckFilter] public object Get() { Config cfg = Config.GetSystemConfig(); @@ -37,10 +38,19 @@ namespace COMCMS.Web.Controllers.api /// [HttpGet] [CheckFilter] - public ReJson CheckSign(string id, string random = "", string timeStamp = "", string signature = "") + public ReJson CheckSign(string id) { return new ReJson("验签成功!"); } + + //POST验证 + [HttpPost] + [CheckFilter] + public ReJson ChekSignWidhPost(int id) + { + return new ReJson("验证通过!"); + } + #endregion //#region 测试出错 diff --git a/COMCMS.Web/Controllers/api/PaymentController.cs b/COMCMS.Web/Controllers/api/PaymentController.cs index e0c2408..eaa9e43 100644 --- a/COMCMS.Web/Controllers/api/PaymentController.cs +++ b/COMCMS.Web/Controllers/api/PaymentController.cs @@ -22,7 +22,7 @@ namespace COMCMS.Web.Controllers.api #region 微信小程序订单支付 [HttpGet] [CheckFilter] - public ReJson DoPayOrder(string ordernum, string random = "", string timeStamp = "", string signature = "") + public ReJson DoPayOrder(string ordernum) { //获取订单 Order entity = Order.Find(Order._.OrderNum == ordernum); @@ -59,21 +59,26 @@ namespace COMCMS.Web.Controllers.api return new ReJson(40000, "用户状态错误,无法使用本功能!"); } //开始生成支付订单 - OnlinePayOrder model = new OnlinePayOrder(); - model.OrderId = entity.Id; - model.OrderNum = entity.OrderNum; - model.PayId = 1; - model.PaymentNotes = "微信支付"; - model.PaymentStatus = Utils.PaymentState[0]; - model.PayOrderNum = Utils.GetOrderNum();//在线支付订单的订单号 - model.PayType = "微信支付"; - model.TotalPrice = entity.TotalPay; - model.TotalQty = entity.TotalQty; - model.UId = entity.UId; - model.IP = Utils.GetIP(); - model.IsOK = 0; - model.AddTime = DateTime.Now; - model.Insert(); + OnlinePayOrder model = OnlinePayOrder.Find(OnlinePayOrder._.OrderNum == entity.OrderNum); + if(model == null) + { + model = new OnlinePayOrder(); + model.OrderId = entity.Id; + model.OrderNum = entity.OrderNum; + model.PayId = 1; + model.PaymentNotes = "微信支付"; + model.PaymentStatus = Utils.PaymentState[0]; + model.PayOrderNum = Utils.GetOrderNum();//在线支付订单的订单号 + model.PayType = "微信支付"; + model.TotalPrice = entity.TotalPay; + model.TotalQty = entity.TotalQty; + model.UId = entity.UId; + model.Ip = Utils.GetIP(); + model.IsOK = 0; + model.AddTime = DateTime.Now; + model.Insert(); + } + //写入日志 OrderLog log = new OrderLog(); @@ -92,7 +97,7 @@ namespace COMCMS.Web.Controllers.api - TenPayV3Info TenPayV3Info = new TenPayV3Info(appId, appSecrect, wxmchId, wxmchKey, Utils.GetServerUrl() + "/wxpayment/notify", Utils.GetServerUrl() + "/wxpayment/notify"); + TenPayV3Info TenPayV3Info = new TenPayV3Info(appId, appSecrect, wxmchId, wxmchKey,"","", Utils.GetServerUrl() + "/wxpayment/notify", Utils.GetServerUrl() + "/wxpayment/notify"); TenPayV3Info.TenPayV3Notify = Utils.GetServerUrl() + "/wxpayment/notify"; XTrace.WriteLine("微信支付异步通知地址:" + TenPayV3Info.TenPayV3Notify); //创建支付应答对象 @@ -102,7 +107,7 @@ namespace COMCMS.Web.Controllers.api string rtimeStamp = Utils.GetTimeStamp(); //创建请求统一订单接口参数 - var xmlDataInfo = new TenPayV3UnifiedorderRequestData(TenPayV3Info.AppId, TenPayV3Info.MchId, entity.Title, model.PayOrderNum, (int)(entity.TotalPay * 100), Utils.GetIP(), TenPayV3Info.TenPayV3Notify, Senparc.Weixin.TenPay.TenPayV3Type.JSAPI, my.WeixinAppOpenId, TenPayV3Info.Key, nonceStr); + var xmlDataInfo = new TenPayV3UnifiedorderRequestData(TenPayV3Info.AppId, TenPayV3Info.MchId, entity.Title, model.OrderNum, (int)(entity.TotalPay * 100), Utils.GetIP(), TenPayV3Info.TenPayV3Notify, Senparc.Weixin.TenPay.TenPayV3Type.JSAPI, my.WeixinAppOpenId, TenPayV3Info.Key, nonceStr); //返回给微信的请求 RequestHandler res = new RequestHandler(null); diff --git a/COMCMS.Web/Controllers/api/ProductController.cs b/COMCMS.Web/Controllers/api/ProductController.cs index 322343f..6c142f7 100644 --- a/COMCMS.Web/Controllers/api/ProductController.cs +++ b/COMCMS.Web/Controllers/api/ProductController.cs @@ -11,7 +11,6 @@ using XCode; using System.Web; using COMCMS.Web.Filter; using NewLife.Log; -using static COMCMS.Web.Models.APIModels; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Senparc.Weixin.WxOpen; @@ -34,7 +33,7 @@ namespace COMCMS.Web.Controllers.api /// [HttpGet] [CheckFilter] - public object GetCategories(int level, int pid = 0, string random = "", string timeStamp = "", string signature = "") + public object GetCategories(int level, int pid = 0) { var list = Category.GetListTree(pid, level, false, false); @@ -74,7 +73,7 @@ namespace COMCMS.Web.Controllers.api /// [HttpGet] [CheckFilter] - public object GetProductList(int kid, int page, int pageSize = 10, string random = "", string timeStamp = "", string signature = "") + public object GetProductList(int kid, int page, int pageSize = 10) { var where = Product._.IsHide == 0; if (kid > 0) diff --git a/COMCMS.Web/Controllers/api/UserController.cs b/COMCMS.Web/Controllers/api/UserController.cs index 9f4482c..1f9d664 100644 --- a/COMCMS.Web/Controllers/api/UserController.cs +++ b/COMCMS.Web/Controllers/api/UserController.cs @@ -11,10 +11,10 @@ using XCode; using System.Web; using COMCMS.Web.Filter; using NewLife.Log; -using static COMCMS.Web.Models.APIModels; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Senparc.Weixin.WxOpen; +using COMCMS.Web.Models; namespace COMCMS.Web.Controllers.api { @@ -31,7 +31,7 @@ namespace COMCMS.Web.Controllers.api /// [HttpGet] [CheckFilter] - public ReJson UserLogin(string code, string random = "", string timeStamp = "", string signature = "") + public ReJson UserLogin(string code) { if (string.IsNullOrEmpty(code)) { @@ -141,7 +141,7 @@ namespace COMCMS.Web.Controllers.api /// /// [HttpGet] - public ReJson SyncWeixinInfo(string sessionkey, string userInfo, int inviteid = 0, string random = "", string timeStamp = "", string signature = "") + public ReJson SyncWeixinInfo(string sessionkey, string userInfo, int inviteid = 0) { if (string.IsNullOrEmpty(sessionkey)) { diff --git a/COMCMS.Web/Controllers/wxpaymentController.cs b/COMCMS.Web/Controllers/wxpaymentController.cs index c6de522..9d61bba 100644 --- a/COMCMS.Web/Controllers/wxpaymentController.cs +++ b/COMCMS.Web/Controllers/wxpaymentController.cs @@ -14,10 +14,11 @@ using Senparc.Weixin.TenPay.V3; using System.Collections; using Microsoft.Extensions.Configuration; using Newtonsoft.Json; +using COMCMS.Web.Common; namespace COMCMS.Web.Controllers { - public class wxpaymentController : HomeController + public class wxpaymentController : HomeBaseController { #region 微信支付异步通知 /// @@ -41,7 +42,7 @@ namespace COMCMS.Web.Controllers string wxmchId = cfg.MCHId;// ConfigurationManager.AppSettings["WeixinMCHId"]; string wxmchKey = cfg.MCHKey;// ConfigurationManager.AppSettings["WeixinMCHKey"]; - TenPayV3Info TenPayV3Info = new TenPayV3Info(appId, appSecrect, wxmchId, wxmchKey, Utils.GetServerUrl() + "/wxpayment/notify", Utils.GetServerUrl() + "/wxpayment/notify"); + TenPayV3Info TenPayV3Info = new TenPayV3Info(appId, appSecrect, wxmchId, wxmchKey,"","", Utils.GetServerUrl() + "/wxpayment/notify", Utils.GetServerUrl() + "/wxpayment/notify"); string res = null; resHandler.SetKey(TenPayV3Info.Key); @@ -53,7 +54,7 @@ namespace COMCMS.Web.Controllers string out_trade_no = resHandler.GetParameter("out_trade_no");//商户订单号 XTrace.WriteLine("微信异步通知订单号:" + out_trade_no + ";" + JsonConvert.SerializeObject(resHandler)); - OnlinePayOrder payOrder = OnlinePayOrder.Find(OnlinePayOrder._.PayOrderNum == out_trade_no); + OnlinePayOrder payOrder = OnlinePayOrder.Find(OnlinePayOrder._.OrderNum == out_trade_no); if (payOrder == null) { XTrace.WriteLine($"支付成功,但是支付订单不存在:{out_trade_no}"); @@ -66,6 +67,7 @@ namespace COMCMS.Web.Controllers //更新支付订单 payOrder.PaymentStatus = Utils.PaymentState[1]; payOrder.ReceiveTime = DateTime.Now; + payOrder.OutTradeNo = out_trade_no; payOrder.IsOK = 1; payOrder.Update(); @@ -75,6 +77,8 @@ namespace COMCMS.Web.Controllers { order.PaymentStatus = Utils.PaymentState[1]; order.PayType = "微信支付"; + order.OutTradeNo = out_trade_no; + if (order.MyType == (int)Utils.MyType.分销商认证) { order.OrderStatus = Utils.OrdersState[2]; diff --git a/COMCMS.Web/Filter/CheckFilter.cs b/COMCMS.Web/Filter/CheckFilter.cs index 4996375..4b6fbae 100644 --- a/COMCMS.Web/Filter/CheckFilter.cs +++ b/COMCMS.Web/Filter/CheckFilter.cs @@ -9,8 +9,6 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; - - namespace COMCMS.Web.Filter { public class CheckFilterAttribute : ActionFilterAttribute @@ -33,7 +31,13 @@ namespace COMCMS.Web.Filter } } - throw new Exception(error); + ReJson re = new ReJson(40000, error); + context.Result = new ContentResult() + { + Content = re.ToJson(), + ContentType = "application/json" + }; + //throw new Exception(error); } var notVali = ValiSignature(context.HttpContext); @@ -49,35 +53,60 @@ namespace COMCMS.Web.Filter } } + #region 详细验证 private ReJson ValiSignature(HttpContext context) { var Request = context.Request; - - var queryStrings = Request.Query; - List keys = new List(); - //string[] keys = HttpContext.Current.Request.QueryString.AllKeys; - if (queryStrings == null) - { - throw new Exception("queryStrings Is Null"); - } - foreach (var item in queryStrings.Keys) - { - keys.Add(item); - } SortedDictionary pars = new SortedDictionary(); string signature = ""; - foreach (var k in keys) + string method = Request.Method.ToUpper(); + if (method == "GET") { - if (k != "signature") + var queryStrings = Request.Query; + List keys = new List(); + //string[] keys = HttpContext.Current.Request.QueryString.AllKeys; + if (queryStrings == null) { - string v = Request.Query[k]; - pars.Add(k, v); + return new ReJson(40000, "参数错误!"); } - else + foreach (var item in queryStrings.Keys) { - signature = Request.Query[k]; + keys.Add(item); + } + foreach (var k in keys) + { + if (k != "signature") + { + string v = Request.Query[k]; + pars.Add(k, v); + } + else + { + signature = Request.Query[k]; + } } } + else if(method == "POST") + { + var stream = context.Request.Form; + foreach (var item in stream) + { + if (item.Key != "signature") + { + pars.Add(item.Key, item.Value); + } + else + { + signature = item.Value; + } + } + } + else + { + return new ReJson(50000, "不支持的HTTP方法!"); + } + + //没有签名返回错误 if (string.IsNullOrEmpty(signature)) return new ReJson(40004, "signature 为空!"); @@ -91,12 +120,15 @@ namespace COMCMS.Web.Filter string timeStamp = pars["timeStamp"]; //判断时间有效性 DateTime postTime = Utils.StampToDateTime(timeStamp); - if (postTime < DateTime.Now.AddSeconds(-120))//30秒有效期 + if (postTime < DateTime.UtcNow.AddSeconds(-120))//30秒有效期 { return new ReJson(40004, "signature 错误!", 1); } return null; } + #endregion + + } } diff --git a/COMCMS.Web/Models/APIModels.cs b/COMCMS.Web/Models/APIModels.cs index e899a0a..94948c7 100644 --- a/COMCMS.Web/Models/APIModels.cs +++ b/COMCMS.Web/Models/APIModels.cs @@ -5,57 +5,104 @@ using System.Threading.Tasks; namespace COMCMS.Web.Models { - public class APIModels + #region 修改我的个人资料Model + public class APIModMyInfo { - #region 修改我的个人资料Model - public class APIModMyInfo - { - public string RealName { get; set; } - public string Tel { get; set; } - public string Weixin { get; set; } - public string Alipay { get; set; } - public string BankCardNO { get; set; } - public string Bank { get; set; } - public string SessionKey { get; set; } - } - #endregion - - #region 小程序获得用户信息 - /// - /// 小程序获得用户信息 - /// - public class WXAppUserInfo - { - /// - /// 用户名 - /// - public string nickName { get; set; } - /// - /// 性别 0 未知,1 男,2女 - /// - public int gender { get; set; } - /// - /// 语言 - /// - public string language { get; set; } - /// - /// 城市 - /// - public string city { get; set; } - /// - /// 省份 - /// - public string province { get; set; } - /// - /// 国家 - /// - public string country { get; set; } - /// - /// 用户头像 - /// - public string avatarUrl { get; set; } - } - - #endregion + public string RealName { get; set; } + public string Tel { get; set; } + public string Weixin { get; set; } + public string Alipay { get; set; } + public string BankCardNO { get; set; } + public string Bank { get; set; } + public string SessionKey { get; set; } } + #endregion + + #region 小程序获得用户信息 + /// + /// 小程序获得用户信息 + /// + public class WXAppUserInfo + { + /// + /// 用户名 + /// + public string nickName { get; set; } + /// + /// 性别 0 未知,1 男,2女 + /// + public int gender { get; set; } + /// + /// 语言 + /// + public string language { get; set; } + /// + /// 城市 + /// + public string city { get; set; } + /// + /// 省份 + /// + public string province { get; set; } + /// + /// 国家 + /// + public string country { get; set; } + /// + /// 用户头像 + /// + public string avatarUrl { get; set; } + } + + #endregion + + #region 通用返回信息 + public class ReJson + { + public ReJson(string message) + { + this.message = message; + code = 0; + } + + public ReJson(int code, string message) + { + this.code = code; + this.message = message; + } + + public ReJson(int code, string message, int isReload) + { + this.code = code; + this.message = message; + this.isReload = isReload; + } + + public ReJson(int code, string message, object detail) + { + this.code = code; + this.message = message; + this.detail = detail; + } + + /// + /// 返回代码 0 为正确 + /// + public int code { get; set; } = 40000; + + /// + /// 提示语 + /// + public string message { get; set; } + /// + /// 是否重新加载 + /// + public int isReload { get; set; } = 0; + + /// + /// 数据详情 object + /// + public object detail { get; set; } + } + #endregion } diff --git a/COMCMS.Web/Program.cs b/COMCMS.Web/Program.cs index 1559dfb..e5b5dda 100644 --- a/COMCMS.Web/Program.cs +++ b/COMCMS.Web/Program.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace COMCMS.Web @@ -14,12 +15,14 @@ namespace COMCMS.Web { public static void Main(string[] args) { - BuildWebHost(args).Run(); + CreateHostBuilder(args).Build().Run(); } - public static IWebHost BuildWebHost(string[] args) => - WebHost.CreateDefaultBuilder(args) - .UseStartup() - .Build(); + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }); } } diff --git a/COMCMS.Web/Startup.cs b/COMCMS.Web/Startup.cs index 4451f8d..4fb132c 100644 --- a/COMCMS.Web/Startup.cs +++ b/COMCMS.Web/Startup.cs @@ -4,30 +4,29 @@ using System.Linq; using System.Text.Encodings.Web; using System.Text.Unicode; using System.Threading.Tasks; +using COMCMS.Common; +using COMCMS.Web.Common; +using COMCMS.Web.ExceptionHandler; +using COMCMS.Web.Models; +using Lib.Core.MiddlewareExtension.Extension; +using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.HttpOverrides; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Options; using Microsoft.Extensions.WebEncoders; -using Microsoft.AspNetCore.Mvc; -using COMCMS.Common; -using COMCMS.Web.Models; -using COMCMS.Web.Common; -using COMCMS.Web.ExceptionHandler; -using Lib.Core.MiddlewareExtension.Extension; -using Senparc.Weixin.Entities; +using Newtonsoft.Json.Serialization; using Senparc.CO2NET; +using Senparc.CO2NET.Cache; using Senparc.CO2NET.RegisterServices; using Senparc.Weixin; -using Senparc.CO2NET.Cache; -using System.Configuration; -using Microsoft.AspNetCore.Authentication.Cookies; -using Microsoft.AspNetCore.Http.Features; -using Microsoft.Extensions.Options; +using Senparc.Weixin.Entities; using Senparc.Weixin.RegisterServices; -using Microsoft.AspNetCore.Routing.Constraints; namespace COMCMS.Web { @@ -68,22 +67,28 @@ namespace COMCMS.Web { options.IdleTimeout = TimeSpan.FromSeconds(120); options.Cookie.HttpOnly = true; - + }); //部分系统配置 services.Configure(Configuration.GetSection("SystemSetting")); - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); ; + services + .AddControllersWithViews(options => + { + //记录错误 + options.Filters.Add(); + }) + .AddNewtonsoftJson(options => { + options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); + options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss"; + }); + //防止汉字被自动编码 services.Configure(options => { options.TextEncoderSettings = new TextEncoderSettings(UnicodeRanges.All); }); - //记录错误 - services.AddMvc(options => - { - options.Filters.Add(); - }); + services.AddSenparcGlobalServices(Configuration)//Senparc.CO2NET 全局注册 .AddSenparcWeixinServices(Configuration);//Senparc.Weixin 注册(如果使用Senparc.Weixin SDK则添加) @@ -91,22 +96,27 @@ namespace COMCMS.Web services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(); // 设置表单内容限制 - services.Configure(formOptions => + services.Configure(options => { - formOptions.ValueLengthLimit = int.MaxValue; // 表单内容大小限制,默认4194304,单位byte - formOptions.MultipartBodyLengthLimit = int.MaxValue; // 如果是multipart,默认134217728 + //formOptions.ValueLengthLimit = int.MaxValue; // 表单内容大小限制,默认4194304,单位byte + //formOptions.MultipartBodyLengthLimit = int.MaxValue; // 如果是multipart,默认134217728 + options.ValueCountLimit = int.MaxValue; + options.ValueLengthLimit = int.MaxValue; + options.KeyLengthLimit = int.MaxValue; + options.MultipartBodyLengthLimit = int.MaxValue; + options.MultipartBoundaryLengthLimit = int.MaxValue; }); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider svp, IOptions senparcSetting, IOptions senparcWeixinSetting) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider svp, IOptions senparcSetting, IOptions senparcWeixinSetting) { app.Use(async (context, next) => { context.Response.Headers.Add("X-Frame-Options", "SAMEORIGIN"); await next(); }); - + if (env.IsDevelopment()) { @@ -117,7 +127,7 @@ namespace COMCMS.Web app.UseExceptionHandler("/Home/Error"); app.UseHsts(); } - + //其他错误页面处理 app.UseStatusCodePagesWithReExecute("/StatusCode/{0}"); @@ -129,25 +139,26 @@ namespace COMCMS.Web app.UseCookiePolicy(); app.UseAuthentication(); app.UseStaticHttpContext(); + app.UseRouting(); - app.UseMvc(routes => + app.UseEndpoints(endpoints => { - routes.MapRoute( + endpoints.MapControllerRoute( name: "areas", - template: "{area:exists}/{controller=Index}/{action=Index}/{id?}" + pattern: "{area:exists}/{controller=Index}/{action=Index}/{id?}" ); - routes.MapRoute( + endpoints.MapControllerRoute( name: "default", - template: "{controller=Home}/{action=Index}/{id?}"); - routes.MapRoute( + pattern: "{controller=Home}/{action=Index}/{id?}"); + endpoints.MapControllerRoute( name: "article", - template: "{title}/index.html", - defaults:new { controller ="Home", action= "Article" } + pattern: "{title}/index.html", + defaults: new { controller = "Home", action = "Article" } ); - routes.MapRoute( + endpoints.MapControllerRoute( name: "article2", - template: "{title}/", + pattern: "{title}/", defaults: new { controller = "Home", action = "Article" } ); }); @@ -160,6 +171,7 @@ namespace COMCMS.Web app.UseMiddlewareExtension(new ResultExceptionHandler()); IRegisterService register = RegisterService.Start(env, senparcSetting.Value).UseSenparcGlobal(); + register.UseSenparcWeixin(senparcWeixinSetting.Value, senparcSetting.Value);//微信全局注册,必须! //加入HttpContext //MyHttpContext.ServiceProvider = svp; } diff --git a/COMCMS.Web/Views/Home/Index.cshtml b/COMCMS.Web/Views/Home/Index.cshtml index d92ab5b..81f7567 100644 --- a/COMCMS.Web/Views/Home/Index.cshtml +++ b/COMCMS.Web/Views/Home/Index.cshtml @@ -6,7 +6,6 @@ ViewBag.description = cfg.Description; Article about = ViewBag.about; - IList listLinks = Link.FindAll(Link._.KId == 1, Link._.Sequence.Asc(), null, 0, 0); //处理bannr广告 @@ -18,11 +17,16 @@ @@ -266,13 +280,14 @@
- @{ - IList
listNews1 = Article.FindAll(Article._.KId == 6, Article._.Sequence.Asc(), null, 0, 4); - } -
- - @if (listNews1.Count > 0) - { + @{ + IList
listNews1 = Article.FindAll(Article._.KId == 6, Article._.Sequence.Asc(), null, 0, + 4); + } +
+ + @if (listNews1.Count > 0) + { - } - + } + +
+ -
- - @{ - IList
listNews2 = Article.FindAll(Article._.KId == 7, Article._.Sequence.Asc(), null, 0, 4); - } - @if (listNews2.Count > 0) - { - - } - - -
+ } +
+
@@ -426,51 +440,51 @@ } +
@foreach (var l in listLinks) { -
- -
+
+ +
} -
+
- - diff --git a/COMCMS.Web/Views/Shared/EchoTip.cshtml b/COMCMS.Web/Views/Shared/EchoTip.cshtml new file mode 100644 index 0000000..55d85fd --- /dev/null +++ b/COMCMS.Web/Views/Shared/EchoTip.cshtml @@ -0,0 +1,46 @@ +@{ + Layout = null; + ViewBag.Title = "信息提示"; +} + + + + + + @ViewBag.Title + + + + + + + + + +
+
+
+
@ViewBag.Title
+
+
+
+
+

+ 信息提示
+

+

+ @ViewBag.Message +

+

+ 返回首页 +

+
+
+ + +
+ + + + + \ No newline at end of file diff --git a/COMCMS.Web/Views/Shared/_Layout.cshtml b/COMCMS.Web/Views/Shared/_Layout.cshtml index 6463c3b..56e4a8c 100644 --- a/COMCMS.Web/Views/Shared/_Layout.cshtml +++ b/COMCMS.Web/Views/Shared/_Layout.cshtml @@ -31,12 +31,13 @@ @@ -210,7 +211,7 @@
- @ViewBag.cfg.Copyright 技术支持:COMCMS 粤ICP备8888888号-1 + @ViewBag.cfg.Copyright 技术支持:COMCMS 粤ICP备8888888号-1 Powered by .NET Core 3.1.0 on Windows Server
diff --git a/COMCMS.Web/Views/_ViewImports.cshtml b/COMCMS.Web/Views/_ViewImports.cshtml index 3d96f25..fc984f4 100644 --- a/COMCMS.Web/Views/_ViewImports.cshtml +++ b/COMCMS.Web/Views/_ViewImports.cshtml @@ -3,4 +3,5 @@ @using COMCMS.Core @using COMCMS.Common @using XCode +@using COMCMS.Web.Common @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/COMCMS.Web/wwwroot/editor/ckeditor/CHANGES.md b/COMCMS.Web/wwwroot/editor/ckeditor/CHANGES.md index 1205b92..ce29904 100644 --- a/COMCMS.Web/wwwroot/editor/ckeditor/CHANGES.md +++ b/COMCMS.Web/wwwroot/editor/ckeditor/CHANGES.md @@ -1,6 +1,280 @@ CKEditor 4 Changelog ==================== +## CKEditor 4.13 + +New Features: + +* [#835](https://github.com/ckeditor/ckeditor-dev/issues/835): Extended support for pasting from external applications: + * Added support for pasting rich content from Google Docs with the [Paste from Google Docs](https://ckeditor.com/cke4/addon/pastefromgdocs) plugin. + * Added a new [Paste Tools](https://ckeditor.com/cke4/addon/pastetools) plugin for unified paste handling. +* [#3315](https://github.com/ckeditor/ckeditor-dev/issues/3315): Added support for strikethrough in the [BBCode](https://ckeditor.com/cke4/addon/bbcode) plugin. Thanks to [Alexander Kahl](https://github.com/akahl-owl)! +* [#3175](https://github.com/ckeditor/ckeditor-dev/issues/3175): Introduced selection optimization mechanism for handling incorrect selection behaviors in various browsers: + * [#3256](https://github.com/ckeditor/ckeditor-dev/issues/3256): Triple-clicking in the last table cell and deleting content no longer pulls the content below into the table. + * [#3118](https://github.com/ckeditor/ckeditor-dev/issues/3118): Selecting a paragraph with a triple-click and applying a heading applies the heading only to the selected paragraph. + * [#3161](https://github.com/ckeditor/ckeditor-dev/issues/3161): Double-clicking a `` element containing just one word creates a correct selection including the clicked `` only. +* [#3359](https://github.com/ckeditor/ckeditor-dev/issues/3359): Improved [dialog](https://ckeditor.com/cke4/addon/dialog) positioning and behavior when the dialog is resized or moved, or the browser window is resized. +* [#2227](https://github.com/ckeditor/ckeditor-dev/issues/2227): Added the [`config.linkDefaultProtocol`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-linkDefaultProtocol) configuration option that allows setting the default URL protocol for the [Link](https://ckeditor.com/cke4/addon/link) plugin dialog. +* [#3240](https://github.com/ckeditor/ckeditor-dev/issues/3240): Extended the [`CKEDITOR.plugins.widget#mask`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_plugins_widget.html#property-mask) property to allow masking only the specified part of a [widget](https://ckeditor.com/cke4/addon/widget). +* [#3138](https://github.com/ckeditor/ckeditor-dev/issues/3138): Added the possibility to use the [`widgetDefinition.getClipboardHtml()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_plugins_widget.html#method-getClipboardHtml) method to customize the [widget](https://ckeditor.com/cke4/addon/widget) HTML during copy, cut and drag operations. + +Fixed Issues: + +* [#808](https://github.com/ckeditor/ckeditor-dev/issues/808): Fixed: [Widgets](https://ckeditor.com/cke4/addon/widget) and other content disappear on drag and drop in [read-only mode](https://ckeditor.com/docs/ckeditor4/latest/guide/dev_readonly.html). +* [#3260](https://github.com/ckeditor/ckeditor-dev/issues/3260): Fixed: [Widget](https://ckeditor.com/cke4/addon/widget) drag handler is visible in [read-only mode](https://ckeditor.com/docs/ckeditor4/latest/guide/dev_readonly.html). +* [#3261](https://github.com/ckeditor/ckeditor-dev/issues/3261): Fixed: A [widget](https://ckeditor.com/cke4/addon/widget) initialized using the dialog has an incorrect owner document. +* [#3198](https://github.com/ckeditor/ckeditor-dev/issues/3198): Fixed: Blurring and focusing the editor when a [widget](https://ckeditor.com/cke4/addon/widget) is focused creates an additional undo step. +* [#2859](https://github.com/ckeditor/ckeditor-dev/pull/2859): [IE, Edge] Fixed: Various editor UI elements react to right mouse button click: + * [#2845](https://github.com/ckeditor/ckeditor-dev/issues/2845): [Rich Combo](https://ckeditor.com/cke4/addon/richcombo). + * [#2857](https://github.com/ckeditor/ckeditor-dev/issues/2857): [List Block](https://ckeditor.com/cke4/addon/listblock). + * [#2858](https://github.com/ckeditor/ckeditor-dev/issues/2858): [Menu](https://ckeditor.com/cke4/addon/menu). +* [#3158](https://github.com/ckeditor/ckeditor-dev/issues/3158): [Chrome, Safari] Fixed: [Undo](https://ckeditor.com/cke4/addon/undo) plugin breaks with the filling character. +* [#504](https://github.com/ckeditor/ckeditor-dev/issues/504): [Edge] Fixed: The editor's selection is collapsed to the beginning of the content when focusing the editor for the first time. +* [#3101](https://github.com/ckeditor/ckeditor-dev/issues/3101): Fixed: [`CKEDITOR.dom.range#_getTableElement()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dom_range.html#method-_getTableElement) returns `null` instead of a table element for edge cases. +* [#3287](https://github.com/ckeditor/ckeditor-dev/issues/3287): Fixed: [`CKEDITOR.tools.promise`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_tools_promise.html) initializes incorrectly if an AMD loader is present. +* [#3379](https://github.com/ckeditor/ckeditor-dev/issues/3379): Fixed: Incorrect [`CKEDITOR.editor#getData()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_editor.html#method-getData) call when inserting content into the editor. +* [#941](https://github.com/ckeditor/ckeditor-dev/issues/941): Fixed: An error is thrown after styling a table cell text selected using the native selection when the [Table Selection](https://ckeditor.com/cke4/addon/tableselection) plugin is enabled. +* [#3136](https://github.com/ckeditor/ckeditor-dev/issues/3136): [Firefox] Fixed: Clicking [Balloon Toolbar](https://ckeditor.com/cke4/addon/balloontoolbar) items removes the native table selection. +* [#3381](https://github.com/ckeditor/ckeditor-dev/issues/3381): [IE8] Fixed: The [`CKEDITOR.tools.object.keys()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_tools_object.html#method-keys) method does not accept non-objects. +* [#2395](https://github.com/ckeditor/ckeditor-dev/issues/2395): [Android] Fixed: Focused input in a [dialog](https://ckeditor.com/cke4/addon/dialog) is scrolled out of the viewport when the soft keyboard appears. +* [#453](https://github.com/ckeditor/ckeditor-dev/issues/453): Fixed: [Link](https://ckeditor.com/cke4/addon/link) dialog has an invalid width when the editor is maximized and the browser window is resized. +* [#2138](https://github.com/ckeditor/ckeditor-dev/issues/2138): Fixed: An email address containing a question mark is mishandled by the [Link](https://ckeditor.com/cke4/addon/link) plugin. +* [#14613](https://dev.ckeditor.com/ticket/14613): Fixed: Race condition when loading plugins for an already destroyed editor instance throws an error. +* [#2257](https://github.com/ckeditor/ckeditor-dev/issues/2257): Fixed: The editor throws an exception when destroyed shortly after it was created. +* [#3115](https://github.com/ckeditor/ckeditor-dev/issues/3115): Fixed: Destroying the editor during the initialization throws an error. +* [#3354](https://github.com/ckeditor/ckeditor4/issues/3354): [iOS] Fixed: Pasting no longer works on iOS version 13. +* [#3423](https://github.com/ckeditor/ckeditor4/issues/3423) Fixed: [Bookmarks](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dom_range.html#method-createBookmark) can be created inside temporary elements. + +API Changes: + +* [#3154](https://github.com/ckeditor/ckeditor-dev/issues/3154): Added the [`CKEDITOR.tools.array.some()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_tools_array.html#method-some) method. +* [#3245](https://github.com/ckeditor/ckeditor-dev/issues/3245): Added the [`CKEDITOR.plugins.undo.UndoManager.addFilterRule()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_plugins_undo_UndoManager.html#method-addFilterRule) method that allows filtering undo snapshot contents. +* [#2845](https://github.com/ckeditor/ckeditor-dev/issues/2845): Added the [`CKEDITOR.tools.normalizeMouseButton()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_tools.html#method-normalizeMouseButton) method. +* [#2975](https://github.com/ckeditor/ckeditor-dev/issues/2975): Added the [`CKEDITOR.dom.element#fireEventHandler()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dom_element.html#method-fireEventHandler) method. +* [#3247](https://github.com/ckeditor/ckeditor-dev/issues/3247): Extended the [`CKEDITOR.tools.bind()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_tools.html#method-bind) method to accept arguments for bound functions. +* [#3326](https://github.com/ckeditor/ckeditor-dev/issues/3326): Added the [`CKEDITOR.dom.text#isEmpty()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dom_text.html#method-isEmpty) method. +* [#2423](https://github.com/ckeditor/ckeditor-dev/issues/2423): Added the [`CKEDITOR.plugins.dialog.getModel()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dialog.html#method-getModel) and [`CKEDITOR.plugins.dialog.getMode()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dialog.html#method-getMode) methods with their [`CKEDITOR.plugin.definition`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dialog_definition.html) counterparts, allowing to get the dialog subject of a change. +* [#3124](https://github.com/ckeditor/ckeditor-dev/issues/3124): Added the [`CKEDITOR.dom.element#isDetached()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dom_element.html#method-isDetached) method. + +## CKEditor 4.12.1 + +Fixed Issues: + +* [#3220](https://github.com/ckeditor/ckeditor-dev/issues/3220): Fixed: Prevent [Paste from Word](https://ckeditor.com/cke4/addon/pastefromword) filter from deleting [Page Break](https://ckeditor.com/cke4/addon/pagebreak) elements on paste. + +## CKEditor 4.12 + +New Features: + +* [#2598](https://github.com/ckeditor/ckeditor-dev/issues/2598): Added the [Page Break](https://ckeditor.com/cke4/addon/pagebreak) feature support for the [Paste from Word](https://ckeditor.com/cke4/addon/pastefromword) plugin. +* [#1490](https://github.com/ckeditor/ckeditor-dev/issues/1490): Improved the [Paste from Word](https://ckeditor.com/cke4/addon/pastefromword) plugin to retain table cell borders. +* [#2870](https://github.com/ckeditor/ckeditor-dev/issues/2870): Improved support for preserving the indentation of list items for nested lists pasted with the [Paste from Word](https://ckeditor.com/cke4/addon/pastefromword) plugin. +* [#2048](https://github.com/ckeditor/ckeditor-dev/issues/2048): New [`CKEDITOR.config.image2_maxSize`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-image2_maxSize) configuration option for the [Enhanced Image](https://ckeditor.com/cke4/addon/image2) plugin that allows setting a maximum size that an image can be resized to with the resizer. +* [#2639](https://github.com/ckeditor/ckeditor-dev/issues/2639): The [Color Dialog](https://ckeditor.com/cke4/addon/colordialog) plugin now shows the current selection's color when opened. +* [#2084](https://github.com/ckeditor/ckeditor-dev/issues/2084): The [Table Tools](https://ckeditor.com/cke4/addon/tabletools) plugin now allows to change the cell height unit type to either pixels or percent. +* [#3164](https://github.com/ckeditor/ckeditor-dev/issues/3164): The [Table Tools](https://ckeditor.com/cke4/addon/tabletools) plugin now accepts floating point values as the table cell width and height. + +Fixed Issues: + +* [#2672](https://github.com/ckeditor/ckeditor-dev/issues/2672): Fixed: When resizing an [Enhanced Image](https://ckeditor.com/cke4/addon/image2) to a minimum size with the resizer, the image dialog does not show actual values. +* [#1478](https://github.com/ckeditor/ckeditor-dev/issues/1478): Fixed: Custom colors added to [Color Button](https://ckeditor.com/cke4/addon/colorbutton) with the [`config.colorButton_colors`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-colorButton_colors) configuration option in the form of a label or code do not work correctly. +* [#1469](https://github.com/ckeditor/ckeditor-dev/issues/1469): Fixed: Trying to get data from a nested editable inside a freshly pasted widget throws an error. +* [#2235](https://github.com/ckeditor/ckeditor-dev/issues/2235): Fixed: An [Image](https://ckeditor.com/cke4/addon/image) in a table cell has an empty URL field when edited from the context menu opened by right-click when the [Table Selection](https://ckeditor.com/cke4/addon/tableselection) plugin is in use. +* [#3098](https://github.com/ckeditor/ckeditor-dev/issues/3098): Fixed: Unit pickers for table cell width and height in the [Table Tools](https://ckeditor.com/cke4/addon/tabletools) plugin have a different width. +* [#2923](https://github.com/ckeditor/ckeditor-dev/issues/2923): Fixed: The CSS `windowtext` color is not correctly recognized by the [`CKEDITOR.tools.style.parse`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_tools_style_parse.html) methods. +* [#3120](https://github.com/ckeditor/ckeditor-dev/issues/3120): [IE8] Fixed: The [`CKEDITOR.tools.extend()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_tool.html#method-extend) method does not work with the [`DontEnum`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Properties) object property attribute. +* [#2813](https://github.com/ckeditor/ckeditor-dev/issues/2813): Fixed: Editor HTML insertion methods ([`editor.insertHtml()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_editor.html#method-insertHtml), [`editor.insertHtmlIntoRange()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_editor.html#method-insertHtmlIntoRange), [`editor.insertElement()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_editor.html#method-insertElement) and [`editor.insertElementIntoRange()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_editor.html#method-insertElementIntoRange)) pollute the editable with empty `` elements. +* [#2751](https://github.com/ckeditor/ckeditor-dev/issues/2751): Fixed: An editor with [`config.enterMode`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-enterMode) set to [`ENTER_DIV`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR.html#property-ENTER_DIV) alters pasted content. + +API Changes: + +* [#1496](https://github.com/ckeditor/ckeditor-dev/issues/1496): The [Balloon Toolbar](https://ckeditor.com/cke4/addon/balloontoolbar) plugin exposes the [`CKEDITOR.ui.balloonToolbar.reposition()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_ui_balloonToolbar.html#reposition) and [`CKEDITOR.ui.balloonToolbarView.reposition()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_ui_balloonToolbarView.html#reposition) methods. +* [#2021](https://github.com/ckeditor/ckeditor-dev/issues/2021): Added new [`CKEDITOR.dom.documentFragment.find()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dom_documentFragment.html#method-find) and [`CKEDITOR.dom.documentFragment.findOne()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dom_documentFragment.html#method-findOne) methods. +* [#2700](https://github.com/ckeditor/ckeditor-dev/issues/2700): Added the [`CKEDITOR.tools.array.find()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_tools_array.html#method-find) method. +* [#3123](https://github.com/ckeditor/ckeditor-dev/issues/3123): Added the [`CKEDITOR.tools.object.keys()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_tools_object.html#method-keys) method. +* [#3123](https://github.com/ckeditor/ckeditor-dev/issues/3123): Added the [`CKEDITOR.tools.object.entries()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_tools_object.html#method-entries) method. +* [#3123](https://github.com/ckeditor/ckeditor-dev/issues/3123): Added the [`CKEDITOR.tools.object.values()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_tools_object.html#method-values) method. +* [#2821](https://github.com/ckeditor/ckeditor-dev/issues/2821): The [`CKEDITOR.template#source`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_template.html#property-source) property can now be a function, so it can return the changed template values during the runtime. Thanks to [Jacek Pulit](https://github.com/jacek-pulit)! +* [#2598](https://github.com/ckeditor/ckeditor-dev/issues/2598): Added the [`CKEDITOR.plugins.pagebreak.createElement()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_plugins_pagebreak.html#method-createElement) method allowing to create a [Page Break](https://ckeditor.com/cke4/addon/pagebreak) plugin [`CKEDITOR.dom.element`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dom_element.html) instance. +* [#2748](https://github.com/ckeditor/ckeditor-dev/issues/2748): Enhanced error messages thrown when creating an editor on a non-existent element or when trying to instantiate the second editor on the same element. Thanks to [Byran Zaugg](https://github.com/blzaugg)! +* [#2698](https://github.com/ckeditor/ckeditor-dev/issues/2698): Added the [`CKEDITOR.htmlParser.element.findOne()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_htmlParser_element.html#method-findOne) method. +* [#2935](https://github.com/ckeditor/ckeditor-dev/issues/2935): Introduced the [`CKEDITOR.config.pasteFromWord_keepZeroMargins`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-pasteFromWord_keepZeroMargins) configuration option that allows for keeping any `margin-*: 0` style that would be otherwise removed when pasting content with the [Paste from Word](https://ckeditor.com/cke4/addon/pastefromword) plugin. +* [#2962](https://github.com/ckeditor/ckeditor-dev/issues/2962): Added the [`CKEDITOR.tools.promise`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_tools_promise.html) class. +* [#2924](https://github.com/ckeditor/ckeditor-dev/issues/2924): Added the [`CKEDITOR.tools.style.border`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_tools_style_border.html) object wrapping CSS border style helpers under a single type. +* [#2495](https://github.com/ckeditor/ckeditor-dev/issues/2495): The [Table Selection](https://ckeditor.com/cke4/addon/tableselection) plugin can now be disabled for the given table with the `data-cke-tableselection-ignored` attribute. +* [#2692](https://github.com/ckeditor/ckeditor-dev/issues/2692): Plugins can now expose information about the supported environment by implementing the [`pluginDefinition.isSupportedEnvironment()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_pluginDefinition.html#method-isSupportedEnvironment) method. + +Other Changes: + +* [#2741](https://github.com/ckeditor/ckeditor-dev/issues/2741): Replaced deprecated `arguments.callee` calls with named function expressions to allow the editor to work in strict mode. +* [#2924](https://github.com/ckeditor/ckeditor-dev/issues/2924): Marked [`CKEDITOR.tools.style.parse.border()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_tools_style_parse.html#method-border) as deprecated in favor of the [`CKEDITOR.tools.style.border.fromCssRule()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_tools_style_border.html#static-method-fromCssRule) method. +* [#3132](https://github.com/ckeditor/ckeditor-dev/issues/2924): Marked [`CKEDITOR.tools.objectKeys()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_tools.html#method-objectKeys) as deprecated in favor of the [`CKEDITOR.tools.object.keys()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_tools_object.html#method-keys) method. + +## CKEditor 4.11.4 + +Fixed Issues: + +* [#589](https://github.com/ckeditor/ckeditor-dev/issues/589): Fixed: The editor causes memory leaks in create and destroy cycles. +* [#1397](https://github.com/ckeditor/ckeditor-dev/issues/1397): Fixed: Using the dialog to remove headers from a [table](https://ckeditor.com/cke4/addon/table) with one header row only throws an error. +* [#1479](https://github.com/ckeditor/ckeditor-dev/issues/1479): Fixed: [Justification](https://ckeditor.com/cke4/addon/justify) for styled content in BR mode is disabled. +* [#2816](https://github.com/ckeditor/ckeditor-dev/issues/2816): Fixed: [Enhanced Image](https://ckeditor.com/cke4/addon/image2) resize handler is visible in [read-only mode](https://ckeditor.com/docs/ckeditor4/latest/guide/dev_readonly.html). +* [#2874](https://github.com/ckeditor/ckeditor-dev/issues/2874): Fixed: [Enhanced Image](https://ckeditor.com/cke4/addon/image2) resize handler is not created when the editor is initialized in [read-only mode](https://ckeditor.com/docs/ckeditor4/latest/guide/dev_readonly.html). +* [#2775](https://github.com/ckeditor/ckeditor-dev/issues/2775): Fixed: [Clipboard](https://ckeditor.com/cke4/addon/clipboard) paste buttons have wrong state when [read-only](https://ckeditor.com/docs/ckeditor4/latest/guide/dev_readonly.html) mode is set by the mouse event listener with the [Div Editing Area](https://ckeditor.com/cke4/addon/divarea) plugin. +* [#1901](https://github.com/ckeditor/ckeditor-dev/issues/1901): Fixed: Cannot open the context menu over a [Widget](https://ckeditor.com/cke4/addon/widget) with the Shift+F10 keyboard shortcut. + +Other Changes: + +* Updated [WebSpellChecker](https://ckeditor.com/cke4/addon/wsc) (WSC) and [SpellCheckAsYouType](https://ckeditor.com/cke4/addon/scayt) (SCAYT) plugins: + * Language dictionary update: German language was extended with over 600k new words. + * Language dictionary update: Swedish language was extended with over 300k new words. + * Grammar support added for Australian and New Zealand English, Polish, Slovak, Slovenian and Austrian languages. + * Changed wavy red and green lines that underline spelling and grammar errors to straight ones. + * [#55](https://github.com/WebSpellChecker/ckeditor-plugin-wsc/issues/55): Fixed: WSC does not use [`CKEDITOR.getUrl()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR.html#method-getUrl) when referencing style sheets. + * [#166](https://github.com/WebSpellChecker/ckeditor-plugin-scayt/issues/166): Fixed: SCAYT does not use [`CKEDITOR.getUrl()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR.html#method-getUrl) when referencing style sheets. + * [#56](https://github.com/WebSpellChecker/ckeditor-plugin-wsc/issues/56): [Chrome] Fixed: SCAYT/WSC throws errors when running inside a Chrome extension. + * Fixed: After removing a dictionary, the words are not underlined and considered as incorrect. + * Fixed: The Slovenian (`sl_SL`) language does not work. + * Fixed: Quotes with code `U+2019` (Right single quotation mark) are considered separators. + * Fixed: Wrong error message formatting when the service ID is invalid. + * Fixed: Absent languages in the Languages tab when using SCAYT with the [Shared Spaces](https://ckeditor.com/cke4/addon/sharedspace) plugin. + +## CKEditor 4.11.3 + +Fixed Issues: + +* [#2721](https://github.com/ckeditor/ckeditor-dev/issues/2721), [#487](https://github.com/ckeditor/ckeditor-dev/issues/487): Fixed: The order of sublist items is reversed when a higher level list item is removed. +* [#2527](https://github.com/ckeditor/ckeditor-dev/issues/2527): Fixed: [Emoji](https://ckeditor.com/cke4/addon/emoji) autocomplete order does not prioritize emojis with the name starting from the used string. +* [#2572](https://github.com/ckeditor/ckeditor-dev/issues/2572): Fixed: Icons in the [Emoji](https://ckeditor.com/cke4/addon/emoji) dropdown navigation groups are not centered. +* [#1191](https://github.com/ckeditor/ckeditor-dev/issues/1191): Fixed: Items in the [elements path](https://ckeditor.com/cke4/addon/elementspath) are draggable. +* [#2292](https://github.com/ckeditor/ckeditor-dev/issues/2292): Fixed: Dropping a list with a link on the editor's margin causes a console error and removes the dragged text from editor. +* [#2756](https://github.com/ckeditor/ckeditor-dev/issues/2756): Fixed: The [Auto Link](https://ckeditor.com/cke4/addon/autolink) plugin causes an error when typing in the [source editing mode](https://ckeditor.com/docs/ckeditor4/latest/guide/dev_sourcearea.html). +* [#1986](https://github.com/ckeditor/ckeditor-dev/issues/1986): Fixed: The Cell Properties dialog from the [Table Tools](https://ckeditor.com/cke4/addon/tabletools) plugin shows styles that are not allowed through [`config.allowedContent`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-allowedContent). +* [#2565](https://github.com/ckeditor/ckeditor-dev/issues/2565): [IE, Edge] Fixed: Buttons in the [editor toolbar](https://ckeditor.com/cke4/addon/toolbar) are activated by clicking them with the right mouse button. +* [#2792](https://github.com/ckeditor/ckeditor-dev/pull/2792): Fixed: A bug in the [Copy Formatting](https://ckeditor.com/cke4/addon/copyformatting) plugin that caused the following issues: + * [#2780](https://github.com/ckeditor/ckeditor-dev/issues/2780): Fixed: Undo steps disappear after multiple changes of selection. + * [#2470](https://github.com/ckeditor/ckeditor-dev/issues/2470): [Firefox] Fixed: Widget's nested editable gets blurred upon focus. + * [#2655](https://github.com/ckeditor/ckeditor-dev/issues/2655): [Chrome, Safari] Fixed: Widget's nested editable cannot be focused under certain circumstances. + +## CKEditor 4.11.2 + +Fixed Issues: + +* [#2403](https://github.com/ckeditor/ckeditor-dev/issues/2403): Fixed: Styling inline editor initialized inside a table with the [Table Selection](https://ckeditor.com/cke4/addon/tableselection) plugin is causing style leaks. +* [#2514](https://github.com/ckeditor/ckeditor-dev/issues/2403): Fixed: Pasting table data into inline editor initialized inside a table with the [Table Selection](https://ckeditor.com/cke4/addon/tableselection) plugin inserts pasted content into the wrapping table. +* [#2451](https://github.com/ckeditor/ckeditor-dev/issues/2451): Fixed: The [Remove Format](https://ckeditor.com/cke4/addon/removeformat) plugin changes selection. +* [#2546](https://github.com/ckeditor/ckeditor-dev/issues/2546): Fixed: The separator in the toolbar moves when buttons are focused. +* [#2506](https://github.com/ckeditor/ckeditor-dev/issues/2506): Fixed: [Enhanced Image](https://ckeditor.com/cke4/addon/image2) throws a type error when an empty `
` tag with an `image` class is upcasted. +* [#2650](https://github.com/ckeditor/ckeditor-dev/issues/2650): Fixed: [Table](https://ckeditor.com/cke4/addon/table) dialog validator fails when the `getValue()` function is defined in the global scope. +* [#2690](https://github.com/ckeditor/ckeditor-dev/issues/2690): Fixed: Decimal characters are removed from the inside of numbered lists when pasting content using the [Paste from Word](https://ckeditor.com/cke4/addon/pastefromword) plugin. +* [#2205](https://github.com/ckeditor/ckeditor-dev/issues/2205): Fixed: It is not possible to add new list items under an item containing a block element. +* [#2411](https://github.com/ckeditor/ckeditor-dev/issues/2411), [#2438](https://github.com/ckeditor/ckeditor-dev/issues/2438) Fixed: Apply numbered list option throws a console error for a specific markup. +* [#2430](https://github.com/ckeditor/ckeditor-dev/issues/2430) Fixed: [Color Button](https://ckeditor.com/cke4/addon/colorbutton) and [List Block](https://ckeditor.com/cke4/addon/listblock) items are draggable. + +Other Changes: + +* Updated the [WebSpellChecker](https://ckeditor.com/cke4/addon/wsc) (WSC) plugin: + * [#52](https://github.com/WebSpellChecker/ckeditor-plugin-wsc/issues/52) Fixed: Clicking "Finish Checking" without a prior action would hang the Spell Checking dialog. +* [#2603](https://github.com/ckeditor/ckeditor-dev/issues/2603): Corrected the GPL license entry in the `package.json` file. + +## CKEditor 4.11.1 + +Fixed Issues: + +* [#2571](https://github.com/ckeditor/ckeditor-dev/issues/2571): Fixed: Clicking the categories in the [Emoji](https://ckeditor.com/cke4/addon/emoji) dropdown panel scrolls the entire page. + +## CKEditor 4.11 + +**Security Updates:** + +* Fixed XSS vulnerability in the HTML parser reported by [maxarr](https://hackerone.com/maxarr). + + Issue summary: It was possible to execute XSS inside CKEditor after persuading the victim to: (i) switch CKEditor to source mode, then (ii) paste a specially crafted HTML code, prepared by the attacker, into the opened CKEditor source area, and (iii) switch back to WYSIWYG mode. + +**An upgrade is highly recommended!** + +New Features: + +* [#2062](https://github.com/ckeditor/ckeditor-dev/pull/2062): Added the emoji dropdown that allows the user to choose the emoji from the toolbar and search for them using keywords. +* [#2154](https://github.com/ckeditor/ckeditor-dev/issues/2154): The [Link](https://ckeditor.com/cke4/addon/link) plugin now supports phone number links. +* [#1815](https://github.com/ckeditor/ckeditor-dev/issues/1815): The [Auto Link](https://ckeditor.com/cke4/addon/autolink) plugin supports typing link completion. +* [#2478](https://github.com/ckeditor/ckeditor-dev/issues/2478): [Link](https://ckeditor.com/cke4/addon/link) can be inserted using the Ctrl/Cmd + K keystroke. +* [#651](https://github.com/ckeditor/ckeditor-dev/issues/651): Text pasted using the [Paste from Word](https://ckeditor.com/cke4/addon/pastefromword) plugin preserves indentation in paragraphs. +* [#2248](https://github.com/ckeditor/ckeditor-dev/issues/2248): Added support for justification in the [BBCode](https://ckeditor.com/cke4/addon/bbcode) plugin. Thanks to [Matěj Kmínek](https://github.com/KminekMatej)! +* [#706](https://github.com/ckeditor/ckeditor-dev/issues/706): Added a different cursor style when selecting cells for the [Table Selection](https://ckeditor.com/cke4/addon/tableselection) plugin. +* [#2072](https://github.com/ckeditor/ckeditor-dev/issues/2072): The [UI Button](https://ckeditor.com/cke4/addon/button) plugin supports custom `aria-haspopup` property values. The [Menu Button](https://ckeditor.com/cke4/addon/menubutton) `aria-haspopup` value is now `menu`, the [Panel Button](https://ckeditor.com/cke4/addon/panelbutton) and [Rich Combo](https://ckeditor.com/cke4/addon/richcombo) `aria-haspopup` value is now `listbox`. +* [#1176](https://github.com/ckeditor/ckeditor-dev/pull/1176): The [Balloon Panel](https://ckeditor.com/cke4/addon/balloonpanel) can now be attached to a selection instead of an element. +* [#2202](https://github.com/ckeditor/ckeditor-dev/issues/2202): Added the `contextmenu_contentsCss` configuration option to allow adding custom CSS to the [Context Menu](https://ckeditor.com/cke4/addon/contextmenu). + +Fixed Issues: + +* [#1477](https://github.com/ckeditor/ckeditor-dev/issues/1477): Fixed: On destroy, [Balloon Toolbar](https://ckeditor.com/cke4/addon/balloontoolbar) does not destroy its content. +* [#2394](https://github.com/ckeditor/ckeditor-dev/issues/2394): Fixed: [Emoji](https://ckeditor.com/cke4/addon/emoji) dropdown does not show up with repeated symbols in a single line. +* [#1181](https://github.com/ckeditor/ckeditor-dev/issues/1181): [Chrome] Fixed: Opening the context menu in a read-only editor results in an error. +* [#2276](https://github.com/ckeditor/ckeditor-dev/issues/2276): [iOS] Fixed: [Button](https://ckeditor.com/cke4/addon/button) state does not refresh properly. +* [#1489](https://github.com/ckeditor/ckeditor-dev/issues/1489): Fixed: Table contents can be removed in read-only mode when the [Table Selection](https://ckeditor.com/cke4/addon/tableselection) plugin is used. +* [#1264](https://github.com/ckeditor/ckeditor-dev/issues/1264) Fixed: Right-click does not clear the selection created with the [Table Selection](https://ckeditor.com/cke4/addon/tableselection) plugin. +* [#586](https://github.com/ckeditor/ckeditor-dev/issues/586) Fixed: The `required` attribute is not correctly recognized by the [Form Elements](https://ckeditor.com/cke4/addon/forms) plugin dialog. Thanks to [Roli Züger](https://github.com/rzueger)! +* [#2380](https://github.com/ckeditor/ckeditor-dev/issues/2380) Fixed: Styling HTML comments in a top-level element results in extra paragraphs. +* [#2294](https://github.com/ckeditor/ckeditor-dev/issues/2294) Fixed: Pasting content from Microsoft Outlook and then bolding it results in an error. +* [#2035](https://github.com/ckeditor/ckeditor-dev/issues/2035) [Edge] Fixed: `Permission denied` is thrown when opening a [Panel](https://ckeditor.com/cke4/addon/panel) instance. +* [#965](https://github.com/ckeditor/ckeditor-dev/issues/965) Fixed: The [`config.forceSimpleAmpersand`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-forceSimpleAmpersand) option does not work. Thanks to [Alex Maris](https://github.com/alexmaris)! +* [#2448](https://github.com/ckeditor/ckeditor-dev/issues/2448): Fixed: The [`Escape HTML Entities`] plugin with custom [additional entities](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-entities_additional) configuration breaks HTML escaping. +* [#898](https://github.com/ckeditor/ckeditor-dev/issues/898): Fixed: [Enhanced Image](https://ckeditor.com/cke4/addon/image2) long alternative text protrudes into the editor when the image is selected. +* [#1113](https://github.com/ckeditor/ckeditor-dev/issues/1113): [Firefox] Fixed: Nested contenteditable elements path is not updated on focus with the [Div Editing Area](https://ckeditor.com/cke4/addon/divarea) plugin. +* [#1682](https://github.com/ckeditor/ckeditor-dev/issues/1682) Fixed: Hovering the [Balloon Toolbar](https://ckeditor.com/cke4/addon/balloontoolbar) panel changes its size, causing flickering. +* [#421](https://github.com/ckeditor/ckeditor-dev/issues/421) Fixed: Expandable [Button](https://ckeditor.com/cke4/addon/button) puts the `(Selected)` text at the end of the label when clicked. +* [#1454](https://github.com/ckeditor/ckeditor-dev/issues/1454): Fixed: The [`onAbort`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_fileTools_uploadWidgetDefinition.html#property-onAbort) method of the [Upload Widget](https://ckeditor.com/cke4/addon/uploadwidget) is not called when the loader is aborted. +* [#1451](https://github.com/ckeditor/ckeditor-dev/issues/1451): Fixed: The context menu is incorrectly positioned when opened with Shift+F10. +* [#1722](https://github.com/ckeditor/ckeditor-dev/issues/1722): [`CKEDITOR.filter.instances`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_filter.html#static-property-instances) is causing memory leaks. +* [#2491](https://github.com/ckeditor/ckeditor-dev/issues/2491): Fixed: The [Mentions](https://ckeditor.com/cke4/addon/mentions) plugin is not matching diacritic characters. +* [#2519](https://github.com/ckeditor/ckeditor-dev/issues/2519): Fixed: The [Accessibility Help](https://ckeditor.com/cke4/addon/a11yhelp) dialog should display all available keystrokes for a single command. + +API Changes: + +* [#2453](https://github.com/ckeditor/ckeditor-dev/issues/2453): The [`CKEDITOR.ui.panel.block.getItems`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_ui_panel_block.html#method-getItems) method now also returns `input` elements in addition to links. +* [#2224](https://github.com/ckeditor/ckeditor-dev/issues/2224): The [`CKEDITOR.tools.convertToPx`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_tools.html#method-convertToPx) function now converts negative values. +* [#2253](https://github.com/ckeditor/ckeditor-dev/issues/2253): The widget definition [`insert`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_plugins_widget_definition.html#property-insert) method now passes `editor` and `commandData`. Thanks to [marcparmet](https://github.com/marcparmet)! +* [#2045](https://github.com/ckeditor/ckeditor-dev/issues/2045): Extracted [`tools.eventsBuffer`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_tools.html#method-eventsBuffer) and [`tools.throttle`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_tools.html#method-throttle) functions logic into a separate namespace. + * [`tools.eventsBuffer`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_tools.html#method-eventsBuffer) was extracted into [`tools.buffers.event`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_tools_buffers_event.html), + * [`tools.throttle`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_tools.html#method-throttle) was extracted into [`tools.buffers.throttle`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_tools_buffers_throttle.html). +* [#2466](https://github.com/ckeditor/ckeditor-dev/issues/2466): The [`CKEDITOR.filter`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_tools.html#method-constructor) constructor accepts an additional `rules` parameter allowing to bind the editor and filter together. +* [#2493](https://github.com/ckeditor/ckeditor-dev/issues/2493): The [`editor.getCommandKeystroke`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_editor.html#method-getCommandKeystroke) method accepts an additional `all` parameter allowing to retrieve an array of all command keystrokes. +* [#2483](https://github.com/ckeditor/ckeditor-dev/issues/2483): Button's DOM element created with the [`hasArrow`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_ui.html#method-addButton) definition option can by identified by the `.cke_button_expandable` CSS class. + +Other Changes: + +* [#1713](https://github.com/ckeditor/ckeditor-dev/issues/1713): Removed the redundant `lang.title` entry from the [Clipboard](https://ckeditor.com/cke4/addon/clipboard) plugin. + +## CKEditor 4.10.1 + +Fixed Issues: + +* [#2114](https://github.com/ckeditor/ckeditor-dev/issues/2114): Fixed: [Autocomplete](https://ckeditor.com/cke4/addon/autocomplete) cannot be initialized before [`instanceReady`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_editor.html#event-instanceReady). +* [#2107](https://github.com/ckeditor/ckeditor-dev/issues/2107): Fixed: Holding and releasing the mouse button is not inserting an [autocomplete](https://ckeditor.com/cke4/addon/autocomplete) suggestion. +* [#2167](https://github.com/ckeditor/ckeditor-dev/issues/2167): Fixed: Matching in [Emoji](https://ckeditor.com/cke4/addon/emoji) plugin is not case insensitive. +* [#2195](https://github.com/ckeditor/ckeditor-dev/issues/2195): Fixed: [Emoji](https://ckeditor.com/cke4/addon/emoji) shows the suggestion box when the colon is preceded with other characters than white space. +* [#2169](https://github.com/ckeditor/ckeditor-dev/issues/2169): [Edge] Fixed: Error thrown when pasting into the editor. +* [#1084](https://github.com/ckeditor/ckeditor-dev/issues/1084) Fixed: Using the "Automatic" option with [Color Button](https://ckeditor.com/cke4/addon/colorbutton) on a text with the color already defined sets an invalid color value. +* [#2271](https://github.com/ckeditor/ckeditor-dev/issues/2271): Fixed: Custom color name not used as a label in the [Color Button](https://ckeditor.com/cke4/addon/image2) plugin. Thanks to [Eric Geloen](https://github.com/egeloen)! +* [#2296](https://github.com/ckeditor/ckeditor-dev/issues/2296): Fixed: The [Color Button](https://ckeditor.com/cke4/addon/colorbutton) plugin throws an error when activated on content containing HTML comments. +* [#966](https://github.com/ckeditor/ckeditor-dev/issues/966): Fixed: Executing [`editor.destroy()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_editor.html#method-destroy) during the [file upload](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_fileTools_uploadWidgetDefinition.html#property-onUploading) throws an error. Thanks to [Maksim Makarevich](https://github.com/MaksimMakarevich)! +* [#1719](https://github.com/ckeditor/ckeditor-dev/issues/1719): Fixed: Ctrl/Cmd + A inadvertently focuses inline editor if it is starting and ending with a list. Thanks to [theNailz](https://github.com/theNailz)! +* [#1046](https://github.com/ckeditor/ckeditor-dev/issues/1046): Fixed: Subsequent new links do not include the `id` attribute. Thanks to [Nathan Samson](https://github.com/nathansamson)! +* [#1348](https://github.com/ckeditor/ckeditor-dev/issues/1348): Fixed: [Enhanced Image](https://ckeditor.com/cke4/addon/image2) plugin aspect ratio locking uses an old width and height on image URL change. +* [#1791](https://github.com/ckeditor/ckeditor-dev/issues/1791): Fixed: [Image](https://ckeditor.com/cke4/addon/image) and [Enhanced Image](https://ckeditor.com/cke4/addon/image2) plugins can be enabled when [Easy Image](https://ckeditor.com/cke4/addon/easyimage) is present. +* [#2254](https://github.com/ckeditor/ckeditor-dev/issues/2254): Fixed: [Image](https://ckeditor.com/cke4/addon/image) ratio locking is too precise for resized images. Thanks to [Jonathan Gilbert](https://github.com/logiclrd)! +* [#1184](https://github.com/ckeditor/ckeditor-dev/issues/1184): [IE8-11] Fixed: Copying and pasting data in [read-only mode](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_editor.html#property-readOnly) throws an error. +* [#1916](https://github.com/ckeditor/ckeditor-dev/issues/1916): [IE9-11] Fixed: Pressing the Delete key in [read-only mode](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_editor.html#property-readOnly) throws an error. +* [#2003](https://github.com/ckeditor/ckeditor-dev/issues/2003): [Firefox] Fixed: Right-clicking multiple selected table cells containing empty paragraphs removes the selection. +* [#1816](https://github.com/ckeditor/ckeditor-dev/issues/1816): Fixed: Table breaks when Enter is pressed over the [Table Selection](https://ckeditor.com/cke4/addon/tableselection) plugin. +* [#1115](https://github.com/ckeditor/ckeditor-dev/issues/1115): Fixed: The `` tag is not preserved when proper configuration is provided and a style is applied by the [Font](https://ckeditor.com/cke4/addon/font) plugin. +* [#727](https://github.com/ckeditor/ckeditor-dev/issues/727): Fixed: Custom styles may be invisible in the [Styles Combo](https://ckeditor.com/cke4/addon/stylescombo) plugin. +* [#988](https://github.com/ckeditor/ckeditor-dev/issues/988): Fixed: ACF-enabled custom elements prefixed with `object`, `embed`, `param` are removed from the editor content. + +API Changes: + +* [#2249](https://github.com/ckeditor/ckeditor-dev/issues/1791): Added the [`editor.plugins.detectConflict()`](https://ckeditor.com/docs/ckeditor4/latest/CKEDITOR_editor_plugins.html#method-detectConflict) method finding conflicts between provided plugins. + ## CKEditor 4.10 New Features: @@ -8,7 +282,7 @@ New Features: * [#1751](https://github.com/ckeditor/ckeditor-dev/issues/1751): Introduced the **Autocomplete** feature that consists of the following plugins: * [Autocomplete](https://ckeditor.com/cke4/addon/autocomplete) – Provides contextual completion feature for custom text matches based on user input. * [Text Watcher](https://ckeditor.com/cke4/addon/textWatcher) – Checks whether an editor's text change matches the chosen criteria. - * [Text Match](https://ckeditor.com/cke4/addon/textMatch) – Allows to search [`CKEDITOR.dom.range`](https://docs.ckeditor.com/ckeditor4/latest/api/CKEDITOR_dom_range.html) for matching text. + * [Text Match](https://ckeditor.com/cke4/addon/textMatch) – Allows to search [`CKEDITOR.dom.range`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dom_range.html) for matching text. * [#1703](https://github.com/ckeditor/ckeditor-dev/issues/1703): Introduced the [Mentions](https://ckeditor.com/cke4/addon/mentions) plugin providing smart completion feature for custom text matches based on user input starting with a chosen marker character. * [#1746](https://github.com/ckeditor/ckeditor-dev/issues/1703): Introduced the [Emoji](https://ckeditor.com/cke4/addon/emoji) plugin providing completion feature for emoji ideograms. * [#1761](https://github.com/ckeditor/ckeditor-dev/issues/1761): The [Auto Link](https://ckeditor.com/cke4/addon/autolink) plugin now supports email links. @@ -17,22 +291,22 @@ Fixed Issues: * [#1458](https://github.com/ckeditor/ckeditor-dev/issues/1458): [Edge] Fixed: After blurring the editor it takes 2 clicks to focus a widget. * [#1034](https://github.com/ckeditor/ckeditor-dev/issues/1034): Fixed: JAWS leaves forms mode after pressing the Enter key in an inline editor instance. -* [#1748](https://github.com/ckeditor/ckeditor-dev/pull/1748): Fixed: Missing [`CKEDITOR.dialog.definition.onHide`](https://docs.ckeditor.com/ckeditor4/latest/api/CKEDITOR_dialog_definition.html#property-onHide) API documentation. Thanks to [sunnyone](https://github.com/sunnyone)! -* [#1321](https://github.com/ckeditor/ckeditor-dev/issues/1321): Ideographic space character (`\u3000`) is lost when pasting text. -* [#1776](https://github.com/ckeditor/ckeditor-dev/issues/1776): Empty caption placeholder of the [Image Base](https://ckeditor.com/cke4/addon/imagebase) plugin is not hidden when blurred. -* [#1592](https://github.com/ckeditor/ckeditor-dev/issues/1592): The [Image Base](https://ckeditor.com/cke4/addon/imagebase) plugin caption is not visible after paste. -* [#620](https://github.com/ckeditor/ckeditor-dev/issues/620): Fixed: The [`config.forcePasteAsPlainText`](https://docs.ckeditor.com/ckeditor4/latest/api/CKEDITOR_config.html#cfg-forcePasteAsPlainText) option is not respected in internal and cross-editor pasting. +* [#1748](https://github.com/ckeditor/ckeditor-dev/pull/1748): Fixed: Missing [`CKEDITOR.dialog.definition.onHide`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dialog_definition.html#property-onHide) API documentation. Thanks to [sunnyone](https://github.com/sunnyone)! +* [#1321](https://github.com/ckeditor/ckeditor-dev/issues/1321): Fixed: Ideographic space character (`\u3000`) is lost when pasting text. +* [#1776](https://github.com/ckeditor/ckeditor-dev/issues/1776): Fixed: Empty caption placeholder of the [Image Base](https://ckeditor.com/cke4/addon/imagebase) plugin is not hidden when blurred. +* [#1592](https://github.com/ckeditor/ckeditor-dev/issues/1592): Fixed: The [Image Base](https://ckeditor.com/cke4/addon/imagebase) plugin caption is not visible after paste. +* [#620](https://github.com/ckeditor/ckeditor-dev/issues/620): Fixed: The [`config.forcePasteAsPlainText`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-forcePasteAsPlainText) option is not respected in internal and cross-editor pasting. * [#1467](https://github.com/ckeditor/ckeditor-dev/issues/1467): Fixed: The resizing cursor of the [Table Resize](https://ckeditor.com/cke4/addon/tableresize) plugin appearing in the middle of a merged cell. API Changes: * [#850](https://github.com/ckeditor/ckeditor-dev/issues/850): Backward incompatibility: Replaced the `replace` dialog from the [Find / Replace](https://ckeditor.com/cke4/addon/find) plugin with a `tabId` option in the `find` command. -* [#1582](https://github.com/ckeditor/ckeditor-dev/issues/1582): The [`CKEDITOR.editor.addCommand()`](https://docs.ckeditor.com/ckeditor4/latest/api/CKEDITOR_editor.html#method-addCommand) method can now accept a [`CKEDITOR.command`](https://docs.ckeditor.com/ckeditor4/latest/api/CKEDITOR_command.html) instance as a parameter. -* [#1712](https://github.com/ckeditor/ckeditor-dev/issues/1712): The [`extraPlugins`](https://docs.ckeditor.com/ckeditor4/latest/api/CKEDITOR_config.html#cfg-extraPlugins), [`removePlugins`](https://docs.ckeditor.com/ckeditor4/latest/api/CKEDITOR_config.html#cfg-removePlugins) and [`plugins`](https://docs.ckeditor.com/ckeditor4/latest/api/CKEDITOR_config.html#cfg-plugins) configuration options allow whitespace. -* [#1802](https://github.com/ckeditor/ckeditor-dev/issues/1802): The [`extraPlugins`](https://docs.ckeditor.com/ckeditor4/latest/api/CKEDITOR_config.html#cfg-extraPlugins), [`removePlugins`](https://docs.ckeditor.com/ckeditor4/latest/api/CKEDITOR_config.html#cfg-removePlugins) and [`plugins`](https://docs.ckeditor.com/ckeditor4/latest/api/CKEDITOR_config.html#cfg-plugins) configuration options allow passing plugin names as an array. -* [#1724](https://github.com/ckeditor/ckeditor-dev/issues/1724): Added an option to the [`getClientRect()`](https://docs.ckeditor.com/ckeditor4/latest/api/CKEDITOR_dom_element.html#method-getClientRect) function allowing to retrieve an absolute bounding rectangle of the element, i.e. a position relative to the upper-left corner of the topmost viewport. -* [#1498](https://github.com/ckeditor/ckeditor-dev/issues/1498) : Added a new [`getClientRects()`](https://docs.ckeditor.com/ckeditor4/latest/api/CKEDITOR_dom_range.html#method-getClientRects) method to `CKEDITOR.dom.range`. It returns a list of rectangles for each selected element. -* [#1993](https://github.com/ckeditor/ckeditor-dev/issues/1993): Added the [`CKEDITOR.tools.throttle()`](http://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR_tools.html#method-throttle) function. +* [#1582](https://github.com/ckeditor/ckeditor-dev/issues/1582): The [`CKEDITOR.editor.addCommand()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_editor.html#method-addCommand) method can now accept a [`CKEDITOR.command`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_command.html) instance as a parameter. +* [#1712](https://github.com/ckeditor/ckeditor-dev/issues/1712): The [`extraPlugins`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-extraPlugins), [`removePlugins`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-removePlugins) and [`plugins`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-plugins) configuration options allow whitespace. +* [#1802](https://github.com/ckeditor/ckeditor-dev/issues/1802): The [`extraPlugins`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-extraPlugins), [`removePlugins`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-removePlugins) and [`plugins`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-plugins) configuration options allow passing plugin names as an array. +* [#1724](https://github.com/ckeditor/ckeditor-dev/issues/1724): Added an option to the [`getClientRect()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dom_element.html#method-getClientRect) function allowing to retrieve an absolute bounding rectangle of the element, i.e. a position relative to the upper-left corner of the topmost viewport. +* [#1498](https://github.com/ckeditor/ckeditor-dev/issues/1498) : Added a new [`getClientRects()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dom_range.html#method-getClientRects) method to `CKEDITOR.dom.range`. It returns a list of rectangles for each selected element. +* [#1993](https://github.com/ckeditor/ckeditor-dev/issues/1993): Added the [`CKEDITOR.tools.throttle()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_tools.html#method-throttle) function. Other Changes: @@ -79,9 +353,9 @@ New Features: * [Cloud Services](https://ckeditor.com/cke4/addon/cloudservices) * [Image Base](https://ckeditor.com/cke4/addon/imagebase) * [#1338](https://github.com/ckeditor/ckeditor-dev/issues/1338): Keystroke labels are displayed for function keys (like F7, F8). -* [#643](https://github.com/ckeditor/ckeditor-dev/issues/643): The [File Browser](https://ckeditor.com/cke4/addon/filebrowser) plugin can now upload files using XHR requests. This allows for setting custom HTTP headers using the [`config.fileTools_requestHeaders`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.config-cfg-fileTools_requestHeaders) configuration option. +* [#643](https://github.com/ckeditor/ckeditor-dev/issues/643): The [File Browser](https://ckeditor.com/cke4/addon/filebrowser) plugin can now upload files using XHR requests. This allows for setting custom HTTP headers using the [`config.fileTools_requestHeaders`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-fileTools_requestHeaders) configuration option. * [#1365](https://github.com/ckeditor/ckeditor-dev/issues/1365): The [File Browser](https://ckeditor.com/cke4/addon/filebrowser) plugin uses XHR requests by default. -* [#1399](https://github.com/ckeditor/ckeditor-dev/issues/1399): Added the possibility to set [`CKEDITOR.config.startupFocus`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.config-cfg-startupFocus) as `start` or `end` to specify where the editor focus should be after the initialization. +* [#1399](https://github.com/ckeditor/ckeditor-dev/issues/1399): Added the possibility to set [`CKEDITOR.config.startupFocus`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-startupFocus) as `start` or `end` to specify where the editor focus should be after the initialization. * [#1441](https://github.com/ckeditor/ckeditor-dev/issues/1441): The [Magic Line](https://ckeditor.com/cke4/addon/magicline) plugin line element can now be identified by the `data-cke-magic-line="1"` attribute. Fixed Issues: @@ -89,31 +363,32 @@ Fixed Issues: * [#595](https://github.com/ckeditor/ckeditor-dev/issues/595): Fixed: Pasting does not work on mobile devices. * [#869](https://github.com/ckeditor/ckeditor-dev/issues/869): Fixed: Empty selection clears cached clipboard data in the editor. * [#1419](https://github.com/ckeditor/ckeditor-dev/issues/1419): Fixed: The [Widget Selection](https://ckeditor.com/cke4/addon/widgetselection) plugin selects the editor content with the Alt+A key combination on Windows. -* [#1274](https://github.com/ckeditor/ckeditor-dev/issues/1274): Fixed: [Balloon Toolbar](https://ckeditor.com/cke4/addon/balloontoolbar) does not match a single selected image using the [`contextDefinition.cssSelector`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.plugins.balloontoolbar.contextDefinition-property-cssSelector) matcher. +* [#1274](https://github.com/ckeditor/ckeditor-dev/issues/1274): Fixed: [Balloon Toolbar](https://ckeditor.com/cke4/addon/balloontoolbar) does not match a single selected image using the [`contextDefinition.cssSelector`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_plugins_balloontoolbar_contextDefinition.html#property-cssSelector) matcher. * [#1232](https://github.com/ckeditor/ckeditor-dev/issues/1232): Fixed: [Balloon Toolbar](https://ckeditor.com/cke4/addon/balloontoolbar) buttons should be registered as focusable elements. -* [#1342](https://github.com/ckeditor/ckeditor-dev/issues/1342): Fixed: [Balloon Toolbar](https://ckeditor.com/cke4/addon/balloontoolbar) should be re-positioned after the [`change`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.editor-event-change) event. +* [#1342](https://github.com/ckeditor/ckeditor-dev/issues/1342): Fixed: [Balloon Toolbar](https://ckeditor.com/cke4/addon/balloontoolbar) should be re-positioned after the [`change`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_editor.html#event-change) event. * [#1426](https://github.com/ckeditor/ckeditor-dev/issues/1426): [IE8-9] Fixed: Missing [Balloon Toolbar](https://ckeditor.com/cke4/addon/balloontoolbar) background in the [Kama](https://ckeditor.com/cke4/addon/kama) skin. Thanks to [Christian Elmer](https://github.com/keinkurt)! * [#1470](https://github.com/ckeditor/ckeditor-dev/issues/1470): Fixed: [Balloon Toolbar](https://ckeditor.com/cke4/addon/balloontoolbar) is not visible after drag and drop of a widget it is attached to. * [#1048](https://github.com/ckeditor/ckeditor-dev/issues/1048): Fixed: [Balloon Panel](https://ckeditor.com/cke4/addon/balloonpanel) is not positioned properly when a margin is added to its non-static parent. * [#889](https://github.com/ckeditor/ckeditor-dev/issues/889): Fixed: Unclear error message for width and height fields in the [Image](https://ckeditor.com/cke4/addon/image) and [Enhanced Image](https://ckeditor.com/cke4/addon/image2) plugins. * [#859](https://github.com/ckeditor/ckeditor-dev/issues/859): Fixed: Cannot edit a link after a double-click on the text in the link. -* [#1013](https://github.com/ckeditor/ckeditor-dev/issues/1013): Fixed: [Paste from Word](https://ckeditor.com/cke4/addon/pastefromword) does not work correctly with the [`config.forcePasteAsPlainText`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.config-cfg-forcePasteAsPlainText) option. -* [#1356](https://github.com/ckeditor/ckeditor-dev/issues/1356): Fixed: [Border parse function](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.tools.style.parse-method-border) does not allow spaces in the color value. +* [#1013](https://github.com/ckeditor/ckeditor-dev/issues/1013): Fixed: [Paste from Word](https://ckeditor.com/cke4/addon/pastefromword) does not work correctly with the [`config.forcePasteAsPlainText`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-forcePasteAsPlainText) option. +* [#1356](https://github.com/ckeditor/ckeditor-dev/issues/1356): Fixed: [Border parse function](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_tools_style_parse.html#method-border) does not allow spaces in the color value. * [#1010](https://github.com/ckeditor/ckeditor-dev/issues/1010): Fixed: The CSS `border` shorthand property was incorrectly expanded ignoring the `border-color` style. * [#1535](https://github.com/ckeditor/ckeditor-dev/issues/1535): Fixed: [Widget](https://ckeditor.com/cke4/addon/widget) mouseover border contrast is insufficient. * [#1516](https://github.com/ckeditor/ckeditor-dev/issues/1516): Fixed: Fake selection allows removing content in read-only mode using the Backspace and Delete keys. * [#1570](https://github.com/ckeditor/ckeditor-dev/issues/1570): Fixed: Fake selection allows cutting content in read-only mode using the Ctrl/Cmd + X keys. * [#1363](https://github.com/ckeditor/ckeditor-dev/issues/1363): Fixed: Paste notification is unclear and it might confuse users. + API Changes: -* [#1346](https://github.com/ckeditor/ckeditor-dev/issues/1346): [Balloon Toolbar](https://ckeditor.com/cke4/addon/balloontoolbar) [context manager API](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.plugins.balloontoolbar.contextManager) is now available in the [`pluginDefinition.init()`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.pluginDefinition-method-init) method of the [requiring](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.pluginDefinition-property-requires) plugin. -* [#1530](https://github.com/ckeditor/ckeditor-dev/issues/1530): Added the possibility to use custom icons for [buttons](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR_ui_button.html). +* [#1346](https://github.com/ckeditor/ckeditor-dev/issues/1346): [Balloon Toolbar](https://ckeditor.com/cke4/addon/balloontoolbar) [context manager API](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR.plugins.balloontoolbar.contextManager.html) is now available in the [`pluginDefinition.init()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_pluginDefinition.html#method-init) method of the [requiring](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_pluginDefinition.html#property-requires) plugin. +* [#1530](https://github.com/ckeditor/ckeditor-dev/issues/1530): Added the possibility to use custom icons for [buttons](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_ui_button.html.html). Other Changes: * Updated [SCAYT](https://ckeditor.com/cke4/addon/scayt) (Spell Check As You Type) and [WebSpellChecker](https://ckeditor.com/cke4/addon/wsc) (WSC) plugins: - * SCAYT [`scayt_minWordLength`](https://docs.ckeditor.com/ckeditor4/latest/api/CKEDITOR_config.html#scayt_minWordLength) configuration option now defaults to 3 instead of 4. + * SCAYT [`scayt_minWordLength`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#scayt_minWordLength) configuration option now defaults to 3 instead of 4. * SCAYT default number of suggested words in the context menu changed to 3. * [#90](https://github.com/WebSpellChecker/ckeditor-plugin-scayt/issues/90): Fixed: Selection is lost on link creation if SCAYT highlights the word. * Fixed: SCAYT crashes when the browser `localStorage` is disabled. @@ -129,7 +404,7 @@ Other Changes: **Important Notes:** -* [#1249](https://github.com/ckeditor/ckeditor-dev/issues/1249): Enabled the [Upload Image](https://ckeditor.com/cke4/addon/uploadimage) plugin by default in standard and full presets. Also, it will no longer log an error in case of missing [`config.imageUploadUrl`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.config-cfg-imageUploadUrl) property. +* [#1249](https://github.com/ckeditor/ckeditor-dev/issues/1249): Enabled the [Upload Image](https://ckeditor.com/cke4/addon/uploadimage) plugin by default in standard and full presets. Also, it will no longer log an error in case of missing [`config.imageUploadUrl`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-imageUploadUrl) property. New Features: @@ -138,9 +413,9 @@ New Features: * [#468](https://github.com/ckeditor/ckeditor-dev/issues/468): [Edge] Introduced support for the Clipboard API. * [#607](https://github.com/ckeditor/ckeditor-dev/issues/607): Manually inserted Hex color is prefixed with a hash character (`#`) if needed. It ensures a valid Hex color value is used when setting the table cell border or background color with the [Color Dialog](https://ckeditor.com/cke4/addon/colordialog) window. * [#584](https://github.com/ckeditor/ckeditor-dev/issues/584): [Font size and Family](https://ckeditor.com/cke4/addon/font) and [Format](https://ckeditor.com/cke4/addon/format) drop-downs are not toggleable anymore. Default option to reset styles added. -* [#856](https://github.com/ckeditor/ckeditor-dev/issues/856): Introduced the [`CKEDITOR.tools.keystrokeToArray()`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.tools-method-keystrokeToArray) method. It converts a keystroke into its string representation, returning every key name as a separate array element. -* [#1053](https://github.com/ckeditor/ckeditor-dev/issues/1053): Introduced the [`CKEDITOR.tools.object.merge()`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.tools.object-method-merge) method. It allows to merge two objects, returning the new object with all properties from both objects deeply cloned. -* [#1073](https://github.com/ckeditor/ckeditor-dev/issues/1073): Introduced the [`CKEDITOR.tools.array.every()`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.tools.array-method-every) method. It invokes a given test function on every array element and returns `true` if all elements pass the test. +* [#856](https://github.com/ckeditor/ckeditor-dev/issues/856): Introduced the [`CKEDITOR.tools.keystrokeToArray()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_tools.html#method-keystrokeToArray) method. It converts a keystroke into its string representation, returning every key name as a separate array element. +* [#1053](https://github.com/ckeditor/ckeditor-dev/issues/1053): Introduced the [`CKEDITOR.tools.object.merge()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_tools_object.html#method-merge) method. It allows to merge two objects, returning the new object with all properties from both objects deeply cloned. +* [#1073](https://github.com/ckeditor/ckeditor-dev/issues/1073): Introduced the [`CKEDITOR.tools.array.every()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_tools_array.html#method-every) method. It invokes a given test function on every array element and returns `true` if all elements pass the test. Fixed Issues: @@ -152,18 +427,18 @@ Fixed Issues: * [#842](https://github.com/ckeditor/ckeditor-dev/issues/842): Fixed: List style not restored when toggling list indent level in the [Indent List](https://ckeditor.com/cke4/addon/indentlist) plugin. * [#711](https://github.com/ckeditor/ckeditor-dev/issues/711): Fixed: Dragging widgets should only work with the left mouse button. * [#862](https://github.com/ckeditor/ckeditor-dev/issues/862): Fixed: The "Object Styles" group in the [Styles Combo](https://ckeditor.com/cke4/addon/stylescombo) plugin is visible only if the whole element is selected. -* [#994](https://github.com/ckeditor/ckeditor-dev/pull/994): Fixed: Typo in the [`CKEDITOR.focusManager.focus()`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.focusManager-method-focus) API documentation. Thanks to [benjy](https://github.com/benjy)! -* [#1014](https://github.com/ckeditor/ckeditor-dev/issues/1014): Fixed: The [Table Tools](https://ckeditor.com/cke4/addon/tabletools) Cell Properties dialog is now [Advanced Content Filter](https://docs.ckeditor.com/ckeditor4/docs/#!/guide/dev_acf) aware — it is not possible to change the cell width or height if corresponding styles are disabled. +* [#994](https://github.com/ckeditor/ckeditor-dev/pull/994): Fixed: Typo in the [`CKEDITOR.focusManager.focus()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_focusManager.html#method-focus) API documentation. Thanks to [benjy](https://github.com/benjy)! +* [#1014](https://github.com/ckeditor/ckeditor-dev/issues/1014): Fixed: The [Table Tools](https://ckeditor.com/cke4/addon/tabletools) Cell Properties dialog is now [Advanced Content Filter](https://ckeditor.com/docs/ckeditor4/latest/guide/dev_acf.html) aware — it is not possible to change the cell width or height if corresponding styles are disabled. * [#877](https://github.com/ckeditor/ckeditor-dev/issues/877): Fixed: A list with custom bullets with exotic characters crashes the editor when [pasted from Word](https://ckeditor.com/cke4/addon/pastefromword). * [#605](https://github.com/ckeditor/ckeditor-dev/issues/605): Fixed: Inline widgets do not preserve trailing spaces. -* [#1008](https://github.com/ckeditor/ckeditor-dev/issues/1008): Fixed: Shorthand Hex colors from the [`config.colorButton_colors`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.config-cfg-colorButton_colors) option are not correctly highlighted in the [Color Button](https://ckeditor.com/cke4/addon/colorbutton) Text Color or Background Color panel. -* [#1094](https://github.com/ckeditor/ckeditor-dev/issues/1094): Fixed: Widget definition [`upcast`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.plugins.widget.definition-property-upcasts) methods are called for every element. +* [#1008](https://github.com/ckeditor/ckeditor-dev/issues/1008): Fixed: Shorthand Hex colors from the [`config.colorButton_colors`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-colorButton_colors) option are not correctly highlighted in the [Color Button](https://ckeditor.com/cke4/addon/colorbutton) Text Color or Background Color panel. +* [#1094](https://github.com/ckeditor/ckeditor-dev/issues/1094): Fixed: Widget definition [`upcast`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_plugins_widget_definition.html#property-upcasts) methods are called for every element. * [#1057](https://github.com/ckeditor/ckeditor-dev/issues/1057): Fixed: The [Notification](https://ckeditor.com/addon/notification) plugin overwrites Web Notifications API due to leakage to the global scope. -* [#1068](https://github.com/ckeditor/ckeditor-dev/issues/1068): Fixed: Upload widget paste listener ignores changes to the [`uploadWidgetDefinition`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.fileTools.uploadWidgetDefinition). +* [#1068](https://github.com/ckeditor/ckeditor-dev/issues/1068): Fixed: Upload widget paste listener ignores changes to the [`uploadWidgetDefinition`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR.fileTools.uploadWidgetDefinition.html). * [#921](https://github.com/ckeditor/ckeditor-dev/issues/921): Fixed: [Edge] CKEditor erroneously perceives internal copy and paste as type "external". * [#1213](https://github.com/ckeditor/ckeditor-dev/issues/1213): Fixed: Multiple images uploaded using [Upload Image](https://ckeditor.com/cke4/addon/uploadimage) plugin are randomly duplicated or mangled. * [#532](https://github.com/ckeditor/ckeditor-dev/issues/532): Fixed: Removed an outdated user guide link from the [About](https://ckeditor.com/cke4/addon/about) dialog. -* [#1221](https://github.com/ckeditor/ckeditor-dev/issues/1221): Fixed: Invalid CSS loaded by [Balloon Panel](https://ckeditor.com/cke4/addon/balloonpanel) plugin when [`config.skin`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.config-cfg-skin) is loaded using a custom path. +* [#1221](https://github.com/ckeditor/ckeditor-dev/issues/1221): Fixed: Invalid CSS loaded by [Balloon Panel](https://ckeditor.com/cke4/addon/balloonpanel) plugin when [`config.skin`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-skin) is loaded using a custom path. * [#522](https://github.com/ckeditor/ckeditor-dev/issues/522): Fixed: Widget selection is not removed when widget is inside table cell with [Table Selection](https://ckeditor.com/cke4/addon/tableselection) plugin enabled. * [#1027](https://github.com/ckeditor/ckeditor-dev/issues/1027): Fixed: Cannot add multiple images to the table with [Table Selection](https://ckeditor.com/cke4/addon/tableselection) plugin in certain situations. * [#1069](https://github.com/ckeditor/ckeditor-dev/issues/1069): Fixed: Wrong shape processing by [Paste from Word](https://ckeditor.com/cke4/addon/pastefromword) plugin. @@ -172,9 +447,9 @@ Fixed Issues: API Changes: -* [#1097](https://github.com/ckeditor/ckeditor-dev/issues/1097): Widget [`upcast`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.plugins.widget.definition-property-upcast) methods are now called in the [widget definition's](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.plugins.widget-property-definition) context. -* [#1118](https://github.com/ckeditor/ckeditor-dev/issues/1118): Added the `show` option in the [`balloonPanel.attach()`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.ui.balloonPanel-method-attach) method, allowing to attach a hidden [Balloon Panel](https://ckeditor.com/cke4/addon/balloonpanel) instance. -* [#1145](https://github.com/ckeditor/ckeditor-dev/issues/1145): Added the [`skipNotifications`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.fileTools.uploadWidgetDefinition-property-skipNotifications) option to the [`CKEDITOR.fileTools.uploadWidgetDefinition`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.fileTools.uploadWidgetDefinition), allowing to switch off default notifications displayed by upload widgets. +* [#1097](https://github.com/ckeditor/ckeditor-dev/issues/1097): Widget [`upcast`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_plugins_widget_definition.html#property-upcast) methods are now called in the [widget definition's](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_plugins_widget.html#property-definition) context. +* [#1118](https://github.com/ckeditor/ckeditor-dev/issues/1118): Added the `show` option in the [`balloonPanel.attach()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_ui_balloonPanel.html#method-attach) method, allowing to attach a hidden [Balloon Panel](https://ckeditor.com/cke4/addon/balloonpanel) instance. +* [#1145](https://github.com/ckeditor/ckeditor-dev/issues/1145): Added the [`skipNotifications`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_fileTools_uploadWidgetDefinition.html#property-skipNotifications) option to the [`CKEDITOR.fileTools.uploadWidgetDefinition`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR.fileTools.uploadWidgetDefinition.html), allowing to switch off default notifications displayed by upload widgets. Other Changes: @@ -185,15 +460,15 @@ Other Changes: New Features: -* [#568](https://github.com/ckeditor/ckeditor-dev/issues/568): Added possibility to adjust nested editables' filters using the [`CKEDITOR.filter.disallowedContent`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.filter-property-disallowedContent) property. +* [#568](https://github.com/ckeditor/ckeditor-dev/issues/568): Added possibility to adjust nested editables' filters using the [`CKEDITOR.filter.disallowedContent`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_filter.html#property-disallowedContent) property. Fixed Issues: -* [#554](https://github.com/ckeditor/ckeditor-dev/issues/554): Fixed: [`change`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.editor-event-change) event not fired when typing the first character after pasting into the editor. Thanks to [Daniel Miller](https://github.com/millerdev)! +* [#554](https://github.com/ckeditor/ckeditor-dev/issues/554): Fixed: [`change`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_editor.html#event-change) event not fired when typing the first character after pasting into the editor. Thanks to [Daniel Miller](https://github.com/millerdev)! * [#566](https://github.com/ckeditor/ckeditor-dev/issues/566): Fixed: The CSS `border` shorthand property with zero width (`border: 0px solid #000;`) causes the table to have the border attribute set to 1. * [#779](https://github.com/ckeditor/ckeditor-dev/issues/779): Fixed: The [Remove Format](https://ckeditor.com/cke4/addon/removeformat) plugin removes elements with language definition inserted by the [Language](https://ckeditor.com/cke4/addon/language) plugin. -* [#423](https://github.com/ckeditor/ckeditor-dev/issues/423): Fixed: The [Paste from Word](https://ckeditor.com/cke4/addon/pastefromword) plugin pastes paragraphs into the editor even if [`CKEDITOR.config.enterMode`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.config-cfg-enterMode) is set to `CKEDITOR.ENTER_BR`. -* [#719](https://github.com/ckeditor/ckeditor-dev/issues/719): Fixed: Image inserted using the [Enhanced Image](https://ckeditor.com/cke4/addon/image2) plugin can be resized when the editor is in [read-only mode](https://docs.ckeditor.com/ckeditor4/docs/#!/guide/dev_readonly). +* [#423](https://github.com/ckeditor/ckeditor-dev/issues/423): Fixed: The [Paste from Word](https://ckeditor.com/cke4/addon/pastefromword) plugin pastes paragraphs into the editor even if [`CKEDITOR.config.enterMode`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-enterMode) is set to `CKEDITOR.ENTER_BR`. +* [#719](https://github.com/ckeditor/ckeditor-dev/issues/719): Fixed: Image inserted using the [Enhanced Image](https://ckeditor.com/cke4/addon/image2) plugin can be resized when the editor is in [read-only mode](https://ckeditor.com/docs/ckeditor4/latest/guide/dev_readonly.html). * [#577](https://github.com/ckeditor/ckeditor-dev/issues/577): Fixed: The "Delete Columns" command provided by the [Table Tools](https://ckeditor.com/cke4/addon/tabletools) plugin throws an error when trying to delete columns. * [#867](https://github.com/ckeditor/ckeditor-dev/issues/867): Fixed: Typing into a selected table throws an error. * [#817](https://github.com/ckeditor/ckeditor-dev/issues/817): Fixed: The [Save](https://ckeditor.com/cke4/addon/save) plugin does not work in [Source Mode](https://ckeditor.com/cke4/addon/sourcearea). @@ -202,14 +477,14 @@ Other Changes: * Updated the [WebSpellChecker](https://ckeditor.com/cke4/addon/wsc) plugin: * [#40](https://github.com/WebSpellChecker/ckeditor-plugin-wsc/issues/40): Fixed: IE10 throws an error when spell checking is started. -* [#800](https://github.com/ckeditor/ckeditor-dev/issues/800): Added the [`CKEDITOR.dom.selection.isCollapsed()`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.dom.selection-method-isCollapsed) method which is a simpler way to check if the selection is collapsed. -* [#830](https://github.com/ckeditor/ckeditor-dev/issues/830): Added an option to define which dialog tab should be shown by default when creating [`CKEDITOR.dialogCommand`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.dialogCommand). +* [#800](https://github.com/ckeditor/ckeditor-dev/issues/800): Added the [`CKEDITOR.dom.selection.isCollapsed()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dom_selection.html#method-isCollapsed) method which is a simpler way to check if the selection is collapsed. +* [#830](https://github.com/ckeditor/ckeditor-dev/issues/830): Added an option to define which dialog tab should be shown by default when creating [`CKEDITOR.dialogCommand`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR.dialogCommand.html). ## CKEditor 4.7.2 New Features: -* [#455](https://github.com/ckeditor/ckeditor-dev/issues/455): Added [Advanced Content Filter](https://docs.ckeditor.com/ckeditor4/docs/#!/guide/dev_acf) integration with the [Justify](https://ckeditor.com/cke4/addon/justify) plugin. +* [#455](https://github.com/ckeditor/ckeditor-dev/issues/455): Added [Advanced Content Filter](https://ckeditor.com/docs/ckeditor4/latest/guide/dev_acf.html) integration with the [Justify](https://ckeditor.com/cke4/addon/justify) plugin. Fixed Issues: @@ -223,17 +498,17 @@ Fixed Issues: * [#491](https://github.com/ckeditor/ckeditor-dev/issues/491): Fixed: Unnecessary dependency on the [Editor Toolbar](https://ckeditor.com/cke4/addon/toolbar) plugin inside the [Notification](https://ckeditor.com/cke4/addon/notification) plugin. * [#646](https://github.com/ckeditor/ckeditor-dev/issues/646): Fixed: Error thrown into the browser console after opening the [Styles Combo](https://ckeditor.com/cke4/addon/stylescombo) plugin menu in the editor without any selection. * [#501](https://github.com/ckeditor/ckeditor-dev/issues/501): Fixed: Double click does not open the dialog for modifying anchors inserted via the [Link](https://ckeditor.com/cke4/addon/link) plugin. -* [#9780](https://dev.ckeditor.com/ticket/9780): [IE8-9] Fixed: Clicking inside an empty [read-only](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.editor-property-readOnly) editor throws an error. +* [#9780](https://dev.ckeditor.com/ticket/9780): [IE8-9] Fixed: Clicking inside an empty [read-only](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_editor.html#property-readOnly) editor throws an error. * [#16820](https://dev.ckeditor.com/ticket/16820): [IE10] Fixed: Clicking below a single horizontal rule throws an error. -* [#426](https://github.com/ckeditor/ckeditor-dev/issues/426): Fixed: The [`range.cloneContents()`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.dom.range-method-cloneContents) method selects the whole element when the selection starts at the beginning of that element. -* [#644](https://github.com/ckeditor/ckeditor-dev/issues/644): Fixed: The [`range.extractContents()`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.dom.range-method-extractContents) method returns an incorrect result when multiple nodes are selected. -* [#684](https://github.com/ckeditor/ckeditor-dev/issues/684): Fixed: The [`elementPath.contains()`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.dom.elementPath-method-contains) method incorrectly excludes the last element instead of root when the `fromTop` parameter is set to `true`. +* [#426](https://github.com/ckeditor/ckeditor-dev/issues/426): Fixed: The [`range.cloneContents()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dom_range.html#method-cloneContents) method selects the whole element when the selection starts at the beginning of that element. +* [#644](https://github.com/ckeditor/ckeditor-dev/issues/644): Fixed: The [`range.extractContents()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dom_range.html#method-extractContents) method returns an incorrect result when multiple nodes are selected. +* [#684](https://github.com/ckeditor/ckeditor-dev/issues/684): Fixed: The [`elementPath.contains()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dom_elementPath.html#method-contains) method incorrectly excludes the last element instead of root when the `fromTop` parameter is set to `true`. Other Changes: * Updated the [SCAYT](https://ckeditor.com/cke4/addon/scayt) (Spell Check As You Type) plugin: * [#148](https://github.com/WebSpellChecker/ckeditor-plugin-scayt/issues/148): Fixed: SCAYT leaves underlined word after the CKEditor Replace dialog corrects it. -* [#751](https://github.com/ckeditor/ckeditor-dev/issues/751): Added the [`CKEDITOR.dom.nodeList.toArray()`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.dom.nodeList-method-toArray) method which returns an array representation of a [node list](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.dom.nodeList). +* [#751](https://github.com/ckeditor/ckeditor-dev/issues/751): Added the [`CKEDITOR.dom.nodeList.toArray()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dom_nodeList.html#method-toArray) method which returns an array representation of a [node list](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR.dom.nodeList.html). ## CKEditor 4.7.1 @@ -252,28 +527,28 @@ Fixed Issues: * [#424](https://github.com/ckeditor/ckeditor-dev/issues/424): Fixed: Error thrown by [Tab Key Handling](https://ckeditor.com/cke4/addon/tab) and [Indent List](https://ckeditor.com/cke4/addon/indentlist) plugins when pressing Tab with no selection in inline editor. * [#476](https://github.com/ckeditor/ckeditor-dev/issues/476): Fixed: Anchors inserted with the [Link](https://ckeditor.com/cke4/addon/link) plugin on collapsed selection cannot be edited. * [#417](https://github.com/ckeditor/ckeditor-dev/issues/417): Fixed: The [Table Resize](https://ckeditor.com/cke4/addon/tableresize) plugin throws an error when used with a table with only header or footer rows. -* [#523](https://github.com/ckeditor/ckeditor-dev/issues/523): Fixed: The [`editor.getCommandKeystroke()`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.editor-method-getCommandKeystroke) method does not obtain the correct keystroke. +* [#523](https://github.com/ckeditor/ckeditor-dev/issues/523): Fixed: The [`editor.getCommandKeystroke()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_editor.html#method-getCommandKeystroke) method does not obtain the correct keystroke. * [#534](https://github.com/ckeditor/ckeditor-dev/issues/534): [IE] Fixed: [Paste from Word](https://ckeditor.com/cke4/addon/pastefromword) does not work in Quirks Mode. -* [#450](https://github.com/ckeditor/ckeditor-dev/issues/450): Fixed: [`CKEDITOR.filter`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.filter) incorrectly transforms the `margin` CSS property. +* [#450](https://github.com/ckeditor/ckeditor-dev/issues/450): Fixed: [`CKEDITOR.filter`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR.filter.html) incorrectly transforms the `margin` CSS property. ## CKEditor 4.7 **Important Notes:** -* [#13793](https://dev.ckeditor.com/ticket/13793): The [`embed_provider`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.config-cfg-embed_provider) configuration option for the [Media Embed](https://ckeditor.com/cke4/addon/embed) and [Semantic Media Embed](https://ckeditor.com/cke4/addon/embedsemantic) plugins is no longer preset by default. +* [#13793](https://dev.ckeditor.com/ticket/13793): The [`embed_provider`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-embed_provider) configuration option for the [Media Embed](https://ckeditor.com/cke4/addon/embed) and [Semantic Media Embed](https://ckeditor.com/cke4/addon/embedsemantic) plugins is no longer preset by default. * The [UI Color](https://ckeditor.com/cke4/addon/uicolor) plugin now uses a custom color picker instead of the `YUI 2.7.0` library which has some known vulnerabilities (it's a security precaution, there was no security issue in CKEditor due to the way it was used). New Features: * [#16755](https://dev.ckeditor.com/ticket/16755): Added the [Table Selection](https://ckeditor.com/cke4/addon/tableselection) plugin that lets you select and manipulate an arbitrary rectangular table fragment (a few cells, a row or a column). * [#16961](https://dev.ckeditor.com/ticket/16961): Added support for pasting from Microsoft Excel. -* [#13381](https://dev.ckeditor.com/ticket/13381): Dynamic code evaluation call in [`CKEDITOR.template`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.template) removed. CKEditor can now be used without the `unsafe-eval` Content Security Policy. Thanks to [Caridy Patiño](http://caridy.name)! +* [#13381](https://dev.ckeditor.com/ticket/13381): Dynamic code evaluation call in [`CKEDITOR.template`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR.template.html) removed. CKEditor can now be used without the `unsafe-eval` Content Security Policy. Thanks to [Caridy Patiño](http://caridy.name)! * [#16971](https://dev.ckeditor.com/ticket/16971): Added support for color in the `background` property containing also other styles for table cells in the [Table Tools](https://ckeditor.com/cke4/addon/tabletools) plugin. * [#16847](https://dev.ckeditor.com/ticket/16847): Added support for parsing and inlining any formatting created using the Microsoft Word style system to the [Paste from Word](https://ckeditor.com/cke4/addon/pastefromword) plugin. * [#16818](https://dev.ckeditor.com/ticket/16818): Added table cell height parsing in the [Paste from Word](https://ckeditor.com/cke4/addon/pastefromword) plugin. -* [#16850](https://dev.ckeditor.com/ticket/16850): Added a new [`config.enableContextMenu`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.config-cfg-enableContextMenu) configuration option for enabling and disabling the [context menu](https://ckeditor.com/cke4/addon/contextmenu). -* [#16937](https://dev.ckeditor.com/ticket/16937): The `command` parameter in [`CKEDITOR.editor.getCommandKeystroke()`](http://docs.ckeditor.dev/#!/api/CKEDITOR.editor-method-getCommandKeystroke) now also accepts a command name as an argument. -* [#17010](https://dev.ckeditor.com/ticket/17010): The [`CKEDITOR.dom.range.shrink()`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.dom.range-method-shrink) method now allows for skipping bogus `
` elements. +* [#16850](https://dev.ckeditor.com/ticket/16850): Added a new [`config.enableContextMenu`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-enableContextMenu) configuration option for enabling and disabling the [context menu](https://ckeditor.com/cke4/addon/contextmenu). +* [#16937](https://dev.ckeditor.com/ticket/16937): The `command` parameter in [`CKEDITOR.editor.getCommandKeystroke()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_editor.html#method-getCommandKeystroke) now also accepts a command name as an argument. +* [#17010](https://dev.ckeditor.com/ticket/17010): The [`CKEDITOR.dom.range.shrink()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dom_range.html#method-shrink) method now allows for skipping bogus `
` elements. Fixed Issues: @@ -307,9 +582,9 @@ Fixed Issues: * [#14407](https://dev.ckeditor.com/ticket/14407): [IE] Fixed: Non-editable widgets can be edited. * [#16927](https://dev.ckeditor.com/ticket/16927): Fixed: An error thrown if a bundle containing the [Color Button](https://ckeditor.com/cke4/addon/colorbutton) plugin is run in ES5 strict mode. Thanks to [Igor Rubinovich](https://github.com/IgorRubinovich)! * [#16920](https://dev.ckeditor.com/ticket/16920): Fixed: Several plugins not using the [Dialog](https://ckeditor.com/cke4/addon/dialog) plugin as a direct dependency. -* [PR#336](https://github.com/ckeditor/ckeditor-dev/pull/336): Fixed: Typo in [`CKEDITOR.getCss()`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR-method-getCss) API documentation. Thanks to [knusperpixel](https://github.com/knusperpixel)! +* [PR#336](https://github.com/ckeditor/ckeditor-dev/pull/336): Fixed: Typo in [`CKEDITOR.getCss()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR.html#method-getCss) API documentation. Thanks to [knusperpixel](https://github.com/knusperpixel)! * [#17027](https://dev.ckeditor.com/ticket/17027): Fixed: Command event data should be initialized as an empty object. -* Fixed the behavior of HTML parser when parsing `src`/`srcdoc` attributes of the `