예제 #1
0
        public IList <ReplyInfo> GetReplies(ReplyType type)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("select ReplyId,Keys,MatchType,ReplyType,MessageType,IsDisable,LastEditDate,LastEditor,Content,Type,ActivityId ");
            stringBuilder.Append(" FROM vshop_Reply ");
            stringBuilder.Append(" where ReplyType  = @ReplyType and IsDisable=0");//去掉了按位运算 ReplyType  & @ReplyType= @ReplyType
            stringBuilder.Append(" order by replyid desc");
            DbCommand sqlStringCommand = this.database.GetSqlStringCommand(stringBuilder.ToString());

            this.database.AddInParameter(sqlStringCommand, "ReplyType", DbType.Int32, (int)type);
            List <ReplyInfo> list = new List <ReplyInfo>();

            using (IDataReader dataReader = this.database.ExecuteReader(sqlStringCommand))
            {
                while (dataReader.Read())
                {
                    ReplyInfo     replyInfo = this.ReaderBind(dataReader);
                    TextReplyInfo textReplyInfo;
                    object        obj;
                    switch (replyInfo.MessageType)
                    {
                    case MessageType.Text:
                        textReplyInfo = (replyInfo as TextReplyInfo);
                        obj           = dataReader["Content"];
                        if (obj != null && obj != DBNull.Value)
                        {
                            textReplyInfo.Text = obj.ToString();
                        }
                        list.Add(textReplyInfo);
                        break;

                    case MessageType.News:
                    case MessageType.List:
                    {
                        NewsReplyInfo newsReplyInfo = replyInfo as NewsReplyInfo;
                        newsReplyInfo.NewsMsg = this.GetNewsReplyInfo(newsReplyInfo.Id);
                        list.Add(newsReplyInfo);
                        break;
                    }

                    case (MessageType)3:
                        goto IL_11F;

                    default:
                        goto IL_11F;
                    }
                    continue;
IL_11F:
                    textReplyInfo = (replyInfo as TextReplyInfo);
                    obj           = dataReader["Content"];
                    if (obj != null && obj != DBNull.Value)
                    {
                        textReplyInfo.Text = obj.ToString();
                    }
                    list.Add(textReplyInfo);
                }
            }
            return(list);
        }
예제 #2
0
        public static IWRespBase GoGKey(WX_ApiConfig config, ReplyType rType, string qValue, WReqBase request)
        {
            var gkey = WXKeywordServices.QueryByReplyType(config.CompanyID, rType, qValue);

            if (gkey == null)
            {
                return(null);
            }
            IKey iKey;

            switch (gkey.KeywordType)
            {
            // 文字
            case KeywordType.Text:
                iKey = new ReplyText();
                break;

            // 图文
            case KeywordType.Article:
                iKey = new ReplyArticle();
                break;

            default:
                return(null);
            }
            return(iKey.ReplyContent(config, gkey, request, qValue));
        }
예제 #3
0
        /// <summary>
        /// 获取关于用户自己的回复数
        /// <param name="refUserId">用户ID</param>
        /// </summary>
        public int GetBBReplyCount(Int32 ObjId, ReplyType ObjType, Int32 CreateId, StateType State, Int32 RefUserId, Int32 RefReplyId)
        {
            int             returnValue          = 0;
            MySqlConnection oc                   = ConnectManager.Create();
            MySqlCommand    _cmdGetGenReplyCount = cmdGetGenReplyCount.Clone() as MySqlCommand;

            _cmdGetGenReplyCount.Connection = oc;
            try
            {
                _cmdGetGenReplyCount.Parameters["@ObjId"].Value      = DBConvert.ToDBValue(ObjId);
                _cmdGetGenReplyCount.Parameters["@ObjType"].Value    = DBConvert.ToDBValue((int)ObjType);
                _cmdGetGenReplyCount.Parameters["@CreateId"].Value   = DBConvert.ToDBValue(CreateId);
                _cmdGetGenReplyCount.Parameters["@State"].Value      = DBConvert.ToDBValue((int)State);
                _cmdGetGenReplyCount.Parameters["@RefUserId"].Value  = DBConvert.ToDBValue(RefUserId);
                _cmdGetGenReplyCount.Parameters["@RefReplyId"].Value = DBConvert.ToDBValue(RefReplyId);


                if (oc.State == ConnectionState.Closed)
                {
                    oc.Open();
                }

                returnValue = Convert.ToInt32(_cmdGetGenReplyCount.ExecuteScalar());
            }
            finally
            {
                oc.Close();
                oc.Dispose();
                oc = null;
                _cmdGetGenReplyCount.Dispose();
                _cmdGetGenReplyCount = null;
                GC.Collect();
            }
            return(returnValue);
        }
예제 #4
0
        /// <summary>
        /// 根据关键词和消息类型获取自动回复信息
        /// </summary>
        /// <param name="type">消息类型</param>
        /// <param name="keyWord">关键字</param>
        /// <param name="isList">是否列表</param>
        /// <param name="isReply">是否自动回复</param>
        /// <returns></returns>
        public AutoReplyInfo GetAutoReplyByKey(ReplyType type, string keyWord = "", bool isList = true, bool isReply = false, bool isFollow = false)
        {
            var sql = Context.AutoReplyInfo.Where(d => d.ReplyType == type);

            if (!string.IsNullOrWhiteSpace(keyWord))
            {
                sql = sql.Where(d => d.Keyword == keyWord);
            }
            if (isReply && !isFollow)
            {
                sql = sql.Where(d => d.MatchType == MatchType.Full);
            }
            if (!isList)
            {
                sql = sql.Where(d => d.IsOpen == 0);
            }
            var result = sql.FirstOrDefault();//优先完全匹配查询

            if (result == null && type == ReplyType.Keyword)
            {
                //完全匹配查询无数据,再根据模糊匹配查询数据1234con123
                result = Context.AutoReplyInfo.Where(d => keyWord.Contains(d.Keyword) && d.MatchType == MatchType.Like && d.IsOpen == 0).OrderByDescending(d => d.Id).FirstOrDefault();//如果完全关键字结果为null,在进行模糊匹配,返回最新一条
                if (result == null)
                {
                    //关键字回复内容为空,取消息自动回复内容
                    result = this.GetAutoReplyMsg();
                }
            }

            return(result);
        }
예제 #5
0
        protected string GetReplyTypeName(object obj)
        {
            ReplyType en   = (ReplyType)obj;
            string    str  = string.Empty;
            bool      flag = false;

            if (ReplyType.Subscribe == (en & ReplyType.Subscribe))
            {
                str  = str + "[关注时回复]";
                flag = true;
            }
            if (ReplyType.NoMatch == (en & ReplyType.NoMatch))
            {
                str  = str + "[无匹配回复]";
                flag = true;
            }
            if (ReplyType.Keys == (en & ReplyType.Keys))
            {
                str  = str + "[关键字回复]";
                flag = true;
            }
            if (!flag)
            {
                str = en.ToShowText();
            }
            return(str);
        }
예제 #6
0
        public List <WX_Keyword> QueryList(string companyId, ReplyType type, string keyValue)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * from WX_Keyword where ReplyType=@ReplyType and  DataStatus!=@DataStatus and CompanyID=@CompanyID");
            using (DbOperator dbOperator = ConnectionManager.CreateReadConnection())
            {
                dbOperator.ClearParameters();
                if (!string.IsNullOrWhiteSpace(keyValue))
                {
                    strSql.Append(" AND  ((Keyword=@Keyword AND MATCHTYPE=@MATCHTYPE) OR (MATCHTYPE=@MATCHTYPE1 AND Keyword LIKE @Keyword1))");
                    dbOperator.AddParameter("Keyword", keyValue);
                    dbOperator.AddParameter("MATCHTYPE", (int)MatchType.Equal);
                    dbOperator.AddParameter("MATCHTYPE1", (int)MatchType.Contains);
                    dbOperator.AddParameter("Keyword1", "%" + keyValue + "%");
                }
                dbOperator.AddParameter("CompanyID", companyId);
                dbOperator.AddParameter("ReplyType", (int)type);
                dbOperator.AddParameter("DataStatus", (int)DataStatus.Delete);
                strSql.Append("  order by ID desc");
                using (DbDataReader reader = dbOperator.ExecuteReader(strSql.ToString()))
                {
                    List <WX_Keyword> models = new List <WX_Keyword>();
                    while (reader.Read())
                    {
                        models.Add(DataReaderToModel <WX_Keyword> .ToModel(reader));
                    }
                    return(models);
                }
            }
        }
예제 #7
0
 public bool UpdateReplyType(int id, ReplyType type)
 {
     using (DbOperator dbOperator = ConnectionManager.CreateConnection())
     {
         return(UpdateReplyType(id, type, dbOperator));
     }
 }
예제 #8
0
        private string GetReplyTypeName(ReplyType type)
        {
            string text = string.Empty;
            bool   flag = false;

            if (ReplyType.Subscribe == (type & ReplyType.Subscribe))
            {
                text += "[关注时回复]";
                flag  = true;
            }
            if (ReplyType.NoMatch == (type & ReplyType.NoMatch))
            {
                text += "[无匹配回复]";
                flag  = true;
            }
            if (ReplyType.Keys == (type & ReplyType.Keys))
            {
                text += "[关键字回复]";
                flag  = true;
            }
            if (!flag)
            {
                text = ((Enum)(object)type).ToShowText();
            }
            return(text);
        }
예제 #9
0
        public bool CheckKeyWord(string companyId, string keyValue, ReplyType rType, int?notContainsId = null)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * from WX_Keyword where ReplyType=@ReplyType and Keyword=@Keyword and DataStatus!=@DataStatus and CompanyID=@CompanyID");
            using (DbOperator dbOperator = ConnectionManager.CreateReadConnection())
            {
                dbOperator.ClearParameters();
                if (notContainsId.HasValue)
                {
                    strSql.Append(" and ID!=@ID");
                    dbOperator.AddParameter("ID", notContainsId.Value);
                }
                dbOperator.AddParameter("CompanyID", companyId);
                dbOperator.AddParameter("ReplyType", (int)rType);
                dbOperator.AddParameter("Keyword", keyValue);
                dbOperator.AddParameter("DataStatus", (int)DataStatus.Delete);
                using (DbDataReader reader = dbOperator.ExecuteReader(strSql.ToString()))
                {
                    if (reader.Read())
                    {
                        return(true);
                    }
                    return(false);
                }
            }
        }
예제 #10
0
        private Tuple <ReceiveType, ReplyType> ParseMessageType(String command)
        {
            // Try to match a numeric code.
            Match results = CommandRegex.Match(command);

            if (results.Success && results.Groups[1].Success)
            {
                String code = results.Groups[1].Value;
                int    intCode;
                if (int.TryParse(code, out intCode))
                {
                    if (Enum.IsDefined(typeof(ReplyType), intCode))
                    {
                        ReplyType reply = (ReplyType)intCode;

                        if ((intCode >= 400) && (intCode <= 599))
                        {
                            return(Tuple.Create(ReceiveType.Error, reply));
                        }
                        else
                        {
                            return(Tuple.Create(ReceiveType.Reply, reply));
                        }
                    }
                }
            }

            // Not a numeric code.
            return(Tuple.Create(ReceiveType.Unknown, ReplyType.Unknown));
        }
예제 #11
0
        public static Reply GetReply(ReplyType rt)
        {
            List <Reply> possibleReplies = m_replies[rt];
            int          rand            = m_generator.Next(0, possibleReplies.Count);

            return(possibleReplies[rand]);
        }
예제 #12
0
        protected string GetReplyTypeName(object obj)
        {
            ReplyType replyType = (ReplyType)obj;
            string    text      = string.Empty;
            bool      flag      = false;

            if (ReplyType.Subscribe == (replyType & ReplyType.Subscribe))
            {
                text += "[关注时回复]";
                flag  = true;
            }
            if (ReplyType.NoMatch == (replyType & ReplyType.NoMatch))
            {
                text += "[无匹配回复]";
                flag  = true;
            }
            if (ReplyType.Keys == (replyType & ReplyType.Keys))
            {
                text += "[关键字回复]";
                flag  = true;
            }
            if (ReplyType.Kefu == replyType)
            {
                text = "[客服回复]";
                flag = true;
            }
            if (!flag)
            {
                text = replyType.ToShowText();
            }
            return(text);
        }
예제 #13
0
        protected string GetReplyTypeName(object obj)
        {
            ReplyType replyType = (ReplyType)obj;
            string    text      = string.Empty;
            bool      flag      = false;

            if (ReplyType.Subscribe == (replyType & ReplyType.Subscribe))
            {
                text += "[<span style='color:orange;'>关注时回复</span>]";
                flag  = true;
            }
            if (ReplyType.NoMatch == (replyType & ReplyType.NoMatch))
            {
                text += "[<span style='color:green;'>无匹配回复</span>]";
                flag  = true;
            }
            if (ReplyType.Keys == (replyType & ReplyType.Keys))
            {
                text += "[关键字回复]";
                flag  = true;
            }
            if (!flag)
            {
                text = replyType.ToShowText();
            }
            return(text);
        }
예제 #14
0
        private void OnCharacterCreateRequest(INetworkConnection con, Packet gmsg)
        {
            PacketGenericMessage msg = gmsg as PacketGenericMessage;
            string rsltMsg           = "";
            ServerCharacterInfo ci   = null;

            if (MyServer.UseCharacters)
            {
                ci = CharacterUtil.Instance.CreateNewCharacter(msg.Parms, ServerUser);
            }

            ReplyType rslt = ReplyType.Failure;

            if (ci != null && OnValidateCharacterCreateRequest(ci, ref rsltMsg))
            {
                if (CharacterUtil.Instance.PersistNewCharacter(ci, ServerUser, ref rsltMsg, !MyServer.RequireAuthentication))
                {
                    rslt = ReplyType.OK;
                }
            }

            PacketReply rep = CreateStandardReply(msg, rslt, rsltMsg);

            msg.ReplyPacket = rep;
        }
예제 #15
0
        /// <summary>
        /// 根据条件分页获取指定数据
        /// <param name="pageIndex">当前页</param>
        /// <para>索引从0开始</para>
        /// <param name="pageSize">每页记录条数</param>
        /// <para>记录数必须大于0</para>
        /// </summary>
        public PageEntity <GenReply> Search(int ObjId, ReplyType ObjType, Int32 CreateId, StateType State, Int32 RefUserId, Int32 RefReplyId, int pageIndex, int pageSize)
        {
            PageEntity <GenReply> returnValue          = new PageEntity <GenReply>();
            List <GenReply>       rlist                = new List <GenReply>();
            MySqlConnection       oc                   = ConnectManager.Create();
            MySqlCommand          _cmdLoadGenReply     = cmdLoadGenReply.Clone() as MySqlCommand;
            MySqlCommand          _cmdGetGenReplyCount = cmdGetGenReplyCount.Clone() as MySqlCommand;

            _cmdLoadGenReply.Connection     = oc;
            _cmdGetGenReplyCount.Connection = oc;

            try
            {
                _cmdLoadGenReply.Parameters["@PageIndex"].Value  = pageIndex * pageSize;
                _cmdLoadGenReply.Parameters["@PageSize"].Value   = (pageIndex + 1) * pageSize;
                _cmdLoadGenReply.Parameters["@ObjId"].Value      = DBConvert.ToDBValue(ObjId);
                _cmdLoadGenReply.Parameters["@ObjType"].Value    = DBConvert.ToDBValue((int)ObjType);
                _cmdLoadGenReply.Parameters["@CreateId"].Value   = DBConvert.ToDBValue(CreateId);
                _cmdLoadGenReply.Parameters["@State"].Value      = DBConvert.ToDBValue((int)State);
                _cmdLoadGenReply.Parameters["@RefUserId"].Value  = DBConvert.ToDBValue(RefUserId);
                _cmdLoadGenReply.Parameters["@RefReplyId"].Value = DBConvert.ToDBValue(RefReplyId);

                _cmdGetGenReplyCount.Parameters["@ObjId"].Value      = DBConvert.ToDBValue(ObjId);
                _cmdGetGenReplyCount.Parameters["@ObjType"].Value    = DBConvert.ToDBValue((int)ObjType);
                _cmdGetGenReplyCount.Parameters["@CreateId"].Value   = DBConvert.ToDBValue(CreateId);
                _cmdGetGenReplyCount.Parameters["@State"].Value      = DBConvert.ToDBValue((int)State);
                _cmdGetGenReplyCount.Parameters["@RefUserId"].Value  = DBConvert.ToDBValue(RefUserId);
                _cmdGetGenReplyCount.Parameters["@RefReplyId"].Value = DBConvert.ToDBValue(RefReplyId);

                if (oc.State == ConnectionState.Closed)
                {
                    oc.Open();
                }

                MySqlDataReader reader = _cmdLoadGenReply.ExecuteReader();
                while (reader.Read())
                {
                    rlist.Add(new GenReply().BuildSampleEntity(reader));
                }
                returnValue.Items = rlist;
                reader.Close();
                returnValue.PageIndex    = pageIndex;
                returnValue.PageSize     = pageSize;
                returnValue.RecordsCount = Convert.ToInt32(_cmdGetGenReplyCount.ExecuteScalar());
            }
            finally
            {
                oc.Close();
                oc.Dispose();
                oc = null;
                _cmdLoadGenReply.Dispose();
                _cmdLoadGenReply = null;
                _cmdGetGenReplyCount.Dispose();
                _cmdGetGenReplyCount = null;
                GC.Collect();
            }
            return(returnValue);
        }
예제 #16
0
        /// <inheritdoc />
        protected override void OnSysexData(ReplyType type, byte[] data)
        {
            if (type != ReplyType.SysexCommand)
            {
                return;
            }

            OnFrequencyReport(data);
        }
예제 #17
0
        private void OnSysexDataInternal(ReplyType type, byte[] data)
        {
            if (_firmata == null)
            {
                return;
            }

            OnSysexData(type, data);
        }
예제 #18
0
파일: ReplyDao.cs 프로젝트: tyriankid/WFX
        public IList <ReplyInfo> GetReplies(ReplyType type)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("select ReplyId,Keys,MatchType,ReplyType,MessageType,IsDisable,LastEditDate,LastEditor,Content,Type,ActivityId ");
            builder.Append(" FROM vshop_Reply ");
            builder.Append(" where ReplyType & @ReplyType = @ReplyType and IsDisable=0");
            builder.Append(" order by replyid desc");

            DbCommand sqlStringCommand = this.database.GetSqlStringCommand(builder.ToString());

            this.database.AddInParameter(sqlStringCommand, "ReplyType", DbType.Int32, (int)type);

            List <ReplyInfo> list = new List <ReplyInfo>();

            using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
            {
                while (reader.Read())
                {
                    TextReplyInfo info3;
                    object        obj2;
                    ReplyInfo     info = this.ReaderBind(reader);
                    switch (info.MessageType)
                    {
                    case MessageType.Text:
                    {
                        info3 = info as TextReplyInfo;
                        obj2  = reader["Content"];
                        if ((obj2 != null) && (obj2 != DBNull.Value))
                        {
                            info3.Text = obj2.ToString();
                        }
                        list.Add(info3);
                        continue;
                    }

                    case MessageType.News:
                    case MessageType.List:
                    {
                        NewsReplyInfo item = info as NewsReplyInfo;
                        item.NewsMsg = this.GetNewsReplyInfo(item.Id);
                        list.Add(item);
                        continue;
                    }
                    }
                    info3 = info as TextReplyInfo;
                    obj2  = reader["Content"];
                    if ((obj2 != null) && (obj2 != DBNull.Value))
                    {
                        info3.Text = obj2.ToString();
                    }
                    list.Add(info3);
                }
            }
            return(list);
        }
예제 #19
0
        public bool UpdateReplyType(int id, ReplyType type, DbOperator dbOperator)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update WX_Keyword set ReplyType=@ReplyType where ID=@ID");
            dbOperator.ClearParameters();
            dbOperator.AddParameter("ReplyType", (int)type);
            dbOperator.AddParameter("ID", id);
            return(dbOperator.ExecuteNonQuery(strSql.ToString()) > 0);
        }
예제 #20
0
        internal ResourcePoolItem <MemoryStream> ReplyBuffer; //for the reply + header

        internal ProcessState(Socket socket, short commandId, short messageId, ReplyType replyType, ResourcePoolItem <MemoryStream> message, int messageLength)
        {
            Socket         = socket;
            CommandId      = commandId;
            MessageId      = messageId;
            ReplyType      = replyType;
            Message        = message;
            MessageLength  = messageLength;
            RemoteEndpoint = (IPEndPoint)socket.RemoteEndPoint;
        }
예제 #21
0
        public IList <ReplyInfo> GetReplies(ReplyType type)
        {
            var replies = _replyRepo.Query().Where(x => x.ReplyType == type).ToList();

            List <ReplyInfo> list = new List <ReplyInfo>();

            foreach (var p in replies)
            {
                TextReplyInfo info3;
                WxReply       info = p;
                switch (info.MessageType)
                {
                default:
                case MessageType.Text:
                    info3 = new TextReplyInfo()
                    {
                        ActivityId   = p.ActivityId,
                        Id           = p.Id,
                        Text         = p.Content,
                        IsDisable    = p.IsDisabled,
                        Keys         = p.Keys,
                        LastEditDate = p.LastModified,
                        LastEditor   = p.LastModifier,
                        MatchType    = p.MatchType,
                        MessageType  = p.MessageType,
                        ReplyType    = p.ReplyType,
                    };
                    list.Add(info3);
                    break;

                case MessageType.News:
                case MessageType.List:
                {
                    NewsReplyInfo item = new Models.NewsReplyInfo()
                    {
                        ActivityId   = p.ActivityId,
                        Id           = p.Id,
                        IsDisable    = p.IsDisabled,
                        Keys         = p.Keys,
                        LastEditDate = p.LastModified,
                        LastEditor   = p.LastModifier,
                        MatchType    = p.MatchType,
                        MessageType  = p.MessageType,
                        ReplyType    = p.ReplyType,
                    };

                    item.NewsMsg = this.GetNewsReplyInfo(item.Id);
                    list.Add(item);
                    break;
                }
                }
            }

            return(list);
        }
예제 #22
0
 public ReceiveMessage(IClientConnection connection, String contents, DateTime date, IMessageTarget sender,
                       IMessageTarget receiver, ReceiveType type, ReplyType replyType)
 {
     Connection = connection;
     Contents   = contents;
     Date       = date;
     Sender     = sender;
     Receiver   = receiver;
     Type       = type;
     ReplyType  = replyType;
 }
예제 #23
0
        public static bool CheckKeyWord(string companyId, string keyValue, ReplyType rType, int?notContainsId = null)
        {
            if (keyValue.IsEmpty())
            {
                throw new ArgumentNullException("keyValue");
            }

            IWXKeyword factory = WXKeywordFactory.GetFactory();

            return(factory.CheckKeyWord(companyId, keyValue, rType, notContainsId));
        }
예제 #24
0
 public ReceiveMessage(IClientConnection connection, String contents, DateTime date, IMessageTarget sender, 
     IMessageTarget receiver, ReceiveType type, ReplyType replyType)
 {
     Connection = connection;
     Contents = contents;
     Date = date;
     Sender = sender;
     Receiver = receiver;
     Type = type;
     ReplyType = replyType;
 }
예제 #25
0
        /// <summary>
        /// 获取关键字回复列表
        /// </summary>
        /// <param name="type"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public QueryPageModel <AutoReplyInfo> GetPage(int pageIndex, int pageSize, ReplyType type)
        {
            QueryPageModel <AutoReplyInfo> result = new QueryPageModel <AutoReplyInfo>();

            var sql  = DbFactory.Default.Get <AutoReplyInfo>().Where(d => d.ReplyType == type);
            var rets = sql.OrderByDescending(o => o.Keyword).ToPagedList(pageIndex, pageSize);

            result.Models = rets;
            result.Total  = rets.TotalRecordCount;
            return(result);
        }
예제 #26
0
        protected void SendGameMessageReply(ServerUser client, ReplyType rp, string msg, Packet inResponseToPacket, PropertyBag parms, bool compress, bool encrypt)
        {
            PacketReply rmsg = client.MyConnection.CreateStandardReply(inResponseToPacket, rp, msg);

            if (parms != null)
            {
                rmsg.Parms = parms;
            }
            rmsg.IsCompressed = compress;
            rmsg.IsEncrypted  = encrypt;
            inResponseToPacket.ReplyPacket = rmsg;
        }
예제 #27
0
        public Reply getStaticReply(ReplyType type)
        {
            Reply reply = new Reply(null, 0);

            switch (type)
            {
            case ReplyType.NO_REPLY:
                reply.reply = "Could you repeat that";
                break;

            case ReplyType.SAME_QUESTION:
                reply.reply = "Try asking me a different question";
                break;
            }
            return(reply);
        }
예제 #28
0
        private void OnCharacterDeleteRequest(INetworkConnection con, Packet gmsg)
        {
            PacketGenericMessage msg = gmsg as PacketGenericMessage;
            string    rsltMsg        = "";
            ReplyType rslt           = ReplyType.Failure;
            int       characterId    = msg.Parms.GetIntProperty((int)PropertyID.CharacterId).GetValueOrDefault();

            if (MyServer.UseCharacters && MyServer.RequireAuthentication && CharacterUtil.Instance.DeleteCharacter(characterId, ServerUser, false, "Player requested deletion from [" + con.RemoteEndPoint.ToString() + "].", ref rsltMsg))
            {
                rslt = ReplyType.OK;
            }

            PacketReply rep = CreateStandardReply(msg, rslt, rsltMsg);

            msg.ReplyPacket = rep;
        }
예제 #29
0
        public static bool UpdateReplyType(int id, ReplyType type)
        {
            if (id < 1)
            {
                throw new ArgumentNullException("id");
            }

            IWXKeyword factory = WXKeywordFactory.GetFactory();
            bool       result  = factory.UpdateReplyType(id, type);

            if (result)
            {
                OperateLogServices.AddOperateLog(string.Format("编号:{0},修改为:{1}", id, type.GetDescription()), OperateType.Update);
            }
            return(result);
        }
예제 #30
0
        public string GetReplyType(ReplyType replyType)
        {
            switch (replyType)
            {
            case ReplyType.Success:
                return(GetResource(TBLocalisation.REPLYTYPE_SUCCESS));

            case ReplyType.Error:
                return(GetResource(TBLocalisation.REPLYTYPE_ERROR));

            case ReplyType.Info:
                return(GetResource(TBLocalisation.REPLYTYPE_INFO));

            default:
                return("");
            }
        }
예제 #31
0
        static Memory <byte> CreateMessage <TSubcmd>(Cmd cmd, TSubcmd subcmd, ReplyType replyType, int dataLength = 0) where TSubcmd : Enum
        {
            if (dataLength < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(dataLength));
            }

            var message = new byte[5 + dataLength];

            message[0] = (byte)message.Length;
            message[1] = 0;
            message[2] = (byte)cmd;
            message[3] = Convert.ToByte(subcmd);
            message[4] = (byte)replyType;

            return(message);
        }
예제 #32
0
 public static IList<ReplyInfo> GetReplies(ReplyType type)
 {
     return new ReplyDao().GetReplies(type);
 }
예제 #33
0
        /// <summary>
        /// Generates a PacketReply based on the packet that is generating this request.
        /// </summary>
        /// <param name="request">the packet that this request is generated for</param>
        /// <param name="replyCode">result of the original reply</param>
        /// <param name="msg">any textual message, or nont at all</param>
        /// <returns></returns>
        public PacketReply CreateStandardReply(Packet request, ReplyType replyCode, string msg)
        {
            if (msg == null)
            {
                msg = "";
            }
            PacketReply p = (PacketReply)CreatePacket((int)PacketType.GenericReply, 0, false, false);
            p.ReplyPacketID = request.PacketID;
            p.ReplyCode = replyCode;
            p.ReplyPacketType = request.PacketTypeID;
            p.ReplyPacketSubType = request.PacketSubTypeID;
            p.ReplyMessage = msg;
            p.IsUDP = request.IsUDP;

            return p;
        }
예제 #34
0
 public IList<ReplyInfo> GetReplies(ReplyType type)
 {
     StringBuilder builder = new StringBuilder();
     builder.Append("select ReplyId,Keys,MatchType,ReplyType,MessageType,IsDisable,LastEditDate,LastEditor,Content,Type,ActivityId ");
     builder.Append(" FROM vshop_Reply ");
     builder.Append(" where ReplyType & @ReplyType = @ReplyType and IsDisable=0");
     builder.Append(" order by replyid desc");
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand(builder.ToString());
     this.database.AddInParameter(sqlStringCommand, "ReplyType", DbType.Int32, (int) type);
     List<ReplyInfo> list = new List<ReplyInfo>();
     using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
     {
         while (reader.Read())
         {
             TextReplyInfo info3;
             object obj2;
             ReplyInfo info = this.ReaderBind(reader);
             switch (info.MessageType)
             {
                 case MessageType.Text:
                 {
                     info3 = info as TextReplyInfo;
                     obj2 = reader["Content"];
                     if ((obj2 != null) && (obj2 != DBNull.Value))
                     {
                         info3.Text = obj2.ToString();
                     }
                     list.Add(info3);
                     continue;
                 }
                 case MessageType.News:
                 case MessageType.List:
                 {
                     NewsReplyInfo item = info as NewsReplyInfo;
                     item.NewsMsg = this.GetNewsReplyInfo(item.Id);
                     list.Add(item);
                     continue;
                 }
             }
             info3 = info as TextReplyInfo;
             obj2 = reader["Content"];
             if ((obj2 != null) && (obj2 != DBNull.Value))
             {
                 info3.Text = obj2.ToString();
             }
             list.Add(info3);
         }
     }
     return list;
 }
예제 #35
0
 public IEnumerable<Reply> GetRepliesByType(ReplyType replyType)
 {
     return _replyRepository.SearchFor(r => r.ReplyType.Equals(replyType)).ToList();
 }
예제 #36
0
 private IReceiveMessage ParseInformationMessage(IMessageTarget sender, ReceiveType type, ReplyType replyType, 
     String parameters)
 {
     return Client.CreateReceiveMessage(Connection, parameters, DateTime.Now, sender, Connection.Me, type,
         replyType);
 }
예제 #37
0
파일: Client.cs 프로젝트: Gohla/ReactiveIRC
 public IReceiveMessage CreateReceiveMessage(IClientConnection connection, String contents, DateTime date,
     IMessageTarget sender, IMessageTarget receiver, ReceiveType type, ReplyType replyType)
 {
     return new ReceiveMessage(connection, contents, date, sender, receiver, type, replyType);
 }
예제 #38
0
 protected void SendGameMessageReply(ServerUser client, ReplyType rp, string msg, Packet inResponseToPacket, PropertyBag parms, bool compress, bool encrypt)
 {
     PacketReply rmsg = client.MyConnection.CreateStandardReply(inResponseToPacket, rp, msg);
     if (parms != null)
     {
         rmsg.Parms = parms;
     }
     rmsg.IsCompressed = compress;
     rmsg.IsEncrypted = encrypt;
     inResponseToPacket.ReplyPacket = rmsg;
 }
예제 #39
0
 protected void SendGameMessageReply(ServerUser client, ReplyType rp, Packet inResponseToPacket, bool compress, bool encrypt)
 {
     SendGameMessageReply(client, rp, "", inResponseToPacket, null, compress, encrypt);
 }
예제 #40
0
        public string GetRandomReply(ReplyType replyType, Message message = null)
        {
            var replies = GetRepliesByType(replyType);
            var rnd = new Random().Next(0, replies.Count());

            return (message != null)
                ? string.Format(replies.ElementAt(rnd).Text, Mention.User(message.User))
                : replies.ElementAt(rnd).Text;
        }