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
}
}