Beispiel #1
0
 private MessageEntity ToEntity(MessageTypeKind commandType, QueryResult result)
 {
     if (commandType == MessageTypeKind.Invalid || commandType == MessageTypeKind.AnyCommand)
     {
         throw new AnycmdException("不能转化为Invalid或AnyCommand类型命令");
     }
     return(new MessageEntity(commandType, this.Id, this.DataTuple)
     {
         Status = result.Status,
         ReasonPhrase = result.ReasonPhrase,
         Description = result.Description,
         CreateOn = DateTime.Now,
         Version = this.Version,
         IsDumb = this.IsDumb,
         Verb = this.Verb,
         ClientId = this.ClientId,
         ClientType = this.ClientType,
         EventSourceType = this.EventSourceType,
         EventSubjectCode = this.EventSubjectCode,
         UserName = this.UserName,
         Ontology = this.Ontology,
         ReceivedOn = this.ReceivedOn,
         MessageId = this.MessageId,
         MessageType = this.MessageType,
         LocalEntityId = this.LocalEntityId,
         CatalogCode = this.CatalogCode,
         TimeStamp = this.TimeStamp,
         From = this.From,
         RelatesTo = this.RelatesTo,
         SessionId = this.SessionId,
         To = this.To
     });
 }
Beispiel #2
0
        public ProcessResult DeleteCommand(MessageTypeKind commandType, OntologyDescriptor ontology, Guid id, bool isDumb)
        {
            ProcessResult r;

            if (isDumb)
            {
                r = ProcessResult.Ok;
            }
            else
            {
                var db          = this.GetCommandDb(ontology);
                var queryString =
                    @"delete " + GetTableName(commandType) + " where Id=@Id";
                int n = db.ExecuteNonQuery(queryString, CreateParameter(db, "Id", id, DbType.Guid));
                if (n == 1)
                {
                    r = ProcessResult.Ok;
                }
                else
                {
                    r = new ProcessResult(new GeneralException("意外的影响行数" + n.ToString(CultureInfo.InvariantCulture)));
                }
            }

            if (r.Exception != null)
            {
                ontology.Host.LoggingService.Error(r.Exception);
            }

            return(r);
        }
Beispiel #3
0
        /// <summary>
        /// 获取给定条目的给定类型的命令
        /// </summary>
        /// <param name="commandType"></param>
        /// <param name="ontology"></param>
        /// <param name="n">条数</param>
        /// <param name="sortField"></param>
        /// <param name="sortOrder"></param>
        /// <returns>命令消息集合</returns>
        public IList <MessageEntity> GetTopNCommands(MessageTypeKind commandType, OntologyDescriptor ontology, int n, string sortField, string sortOrder)
        {
            if (ontology == null)
            {
                return(new List <MessageEntity>());
            }
            if (commandType == MessageTypeKind.Invalid || commandType == MessageTypeKind.AnyCommand)
            {
                return(new List <MessageEntity>());
            }
            var db  = this.GetCommandDb(ontology);
            var sql =
                @"select top " + n.ToString(CultureInfo.InvariantCulture) +
                " * from [" + GetTableName(commandType) + "] as c where lower(c.Ontology)=@Ontology order by c." + sortField + " " + sortOrder;
            var pOntology = CreateParameter(db, "Ontology", ontology.Ontology.Code.ToLower(), DbType.String);
            IList <MessageEntity> list = new List <MessageEntity>();

            using (var reader = db.ExecuteReader(sql, pOntology))
            {
                while (reader.Read())
                {
                    list.Add(CommandRecord.Create(ontology.Host, commandType, reader));
                }
                reader.Close();

                return(list);
            }
        }
        /// <summary>
        /// 根据Id查询命令详细信息
        /// </summary>
        /// <typeparam name="T">命令详细信息展示模型类型参数</typeparam>
        /// <param name="messageProvider">命令提供程序</param>
        /// <param name="messageTypeKind"></param>
        /// <param name="ontology">本体</param>
        /// <param name="id">命令标识</param>
        /// <returns></returns>
        public static MessageTr GetCommandInfo(
            this IMessageProvider messageProvider, MessageTypeKind messageTypeKind, OntologyDescriptor ontology, Guid id)
        {
            var command = messageProvider.GetCommand(messageTypeKind, ontology, id);

            return(MessageTr.Create(ontology.Host, command));
        }
Beispiel #5
0
        public MessageEntity GetCommand(MessageTypeKind commandType, OntologyDescriptor ontology, Guid id)
        {
            var db          = this.GetCommandDb(ontology);
            var queryString =
                @"select * from " + GetTableName(commandType) + " as a where a.Id=@Id";

            using (var reader = db.ExecuteReader(queryString, CreateParameter(db, "Id", id, DbType.Guid)))
            {
                if (reader.Read())
                {
                    return(CommandRecord.Create(ontology.Host, commandType, reader));
                }
            }

            return(null);
        }
        /// <summary>
        /// 分页查询命令展示对象
        /// </summary>
        /// <typeparam name="T">命令展示模型类型参数</typeparam>
        /// <param name="messageProvider">命令提供程序</param>
        /// <param name="messageTypeKind"></param>
        /// <param name="ontology">本体</param>
        /// <param name="catalogCode">目录码</param>
        /// <param name="actionCode">动作码,空值表示忽略本查询条件</param>
        /// <param name="nodeId">节点标识,空值表示忽略本查询条件</param>
        /// <param name="localEntityId"></param>
        /// <param name="pageIndex">页索引</param>
        /// <param name="pageSize">页尺寸</param>
        /// <param name="sortField">排序字段</param>
        /// <param name="sortOrder">排序方向</param>
        /// <param name="total"></param>
        /// <returns></returns>
        public static IList<MessageTr> GetPlistCommandTrs(
            this IMessageProvider messageProvider, MessageTypeKind messageTypeKind, OntologyDescriptor ontology, string catalogCode, string actionCode
            , Guid? nodeId, string localEntityId, int pageIndex, int pageSize
            , string sortField, string sortOrder, out Int64 total)
        {
            IList<MessageEntity> commands = messageProvider.GetPlistCommands(messageTypeKind,
                    ontology, catalogCode, actionCode, nodeId, localEntityId, pageIndex, pageSize
                    , sortField, sortOrder, out total);
            IList<MessageTr> list = new List<MessageTr>();
            foreach (var command in commands)
            {
                list.Add(MessageTr.Create(ontology.Host, command));
            }

            return list;
        }
        /// <summary>
        /// 分页查询命令展示对象
        /// </summary>
        /// <typeparam name="T">命令展示模型类型参数</typeparam>
        /// <param name="messageProvider">命令提供程序</param>
        /// <param name="messageTypeKind"></param>
        /// <param name="ontology">本体</param>
        /// <param name="catalogCode">目录码</param>
        /// <param name="actionCode">动作码,空值表示忽略本查询条件</param>
        /// <param name="nodeId">节点标识,空值表示忽略本查询条件</param>
        /// <param name="localEntityId"></param>
        /// <param name="pageIndex">页索引</param>
        /// <param name="pageSize">页尺寸</param>
        /// <param name="sortField">排序字段</param>
        /// <param name="sortOrder">排序方向</param>
        /// <param name="total"></param>
        /// <returns></returns>
        public static IList <MessageTr> GetPlistCommandTrs(
            this IMessageProvider messageProvider, MessageTypeKind messageTypeKind, OntologyDescriptor ontology, string catalogCode, string actionCode
            , Guid?nodeId, string localEntityId, int pageIndex, int pageSize
            , string sortField, string sortOrder, out Int64 total)
        {
            IList <MessageEntity> commands = messageProvider.GetPlistCommands(messageTypeKind,
                                                                              ontology, catalogCode, actionCode, nodeId, localEntityId, pageIndex, pageSize
                                                                              , sortField, sortOrder, out total);
            IList <MessageTr> list = new List <MessageTr>();

            foreach (var command in commands)
            {
                list.Add(MessageTr.Create(ontology.Host, command));
            }

            return(list);
        }
Beispiel #8
0
 /// <summary>
 /// 构建给定类型的命令。
 /// </summary>
 /// <param name="type">命令类型</param>
 /// <param name="dataTuple">数据项集合对</param>
 /// <param name="id">
 /// 命令标识。
 /// <remarks>
 /// 命令标识在命令的整个生命周期内是不改变的。命令标识在服务端命令创生时生成之后无论命令处在什么状态它的标识都是不变的。
 /// 借助数据库层来说明这个问题:命令从ReceivedMessage表移到ExecutedMessage表的时候主键是不变的。
 /// </remarks>
 /// </param>
 protected MessageBase(MessageTypeKind type, Guid id, DataItemsTuple dataTuple)
 {
     if (type == MessageTypeKind.Invalid)
     {
         throw new AnycmdException("非法的命令类型");
     }
     if (id == Guid.Empty)
     {
         throw new AnycmdException("命令Id不能为空Guid");
     }
     if (dataTuple == null)
     {
         throw new ArgumentNullException("dataTuple");
     }
     Version          = ApiVersion.V1.ToName();
     this.CommandType = type;
     this.Id          = id;
     this.DataTuple   = dataTuple;
 }
Beispiel #9
0
 /// <summary>
 /// 构建给定类型的命令。
 /// </summary>
 /// <param name="type">命令类型</param>
 /// <param name="dataTuple">数据项集合对</param>
 /// <param name="id">
 /// 命令标识。
 /// <remarks>
 /// 命令标识在命令的整个生命周期内是不改变的。命令标识在服务端命令创生时生成之后无论命令处在什么状态它的标识都是不变的。
 /// 借助数据库层来说明这个问题:命令从ReceivedMessage表移到ExecutedMessage表的时候主键是不变的。
 /// </remarks>
 /// </param>
 protected MessageBase(MessageTypeKind type, Guid id, DataItemsTuple dataTuple)
 {
     if (type == MessageTypeKind.Invalid)
     {
         throw new AnycmdException("非法的命令类型");
     }
     if (id == Guid.Empty)
     {
         throw new AnycmdException("命令Id不能为空Guid");
     }
     if (dataTuple == null)
     {
         throw new ArgumentNullException("dataTuple");
     }
     Version = ApiVersion.V1.ToName();
     this.CommandType = type;
     this.Id = id;
     this.DataTuple = dataTuple;
 }
Beispiel #10
0
        private string GetTableName(MessageTypeKind commandType)
        {
            switch (commandType)
            {
            case MessageTypeKind.Invalid:
                throw new GeneralException("意外的命令类型");

            case MessageTypeKind.AnyCommand:
                throw new GeneralException("AnyCommand不能持久化,没有TableName概念。");

            case MessageTypeKind.Received:
                return("ReceivedMessage");

            case MessageTypeKind.Unaccepted:
                return("UnacceptedMessage");

            case MessageTypeKind.Executed:
                return("HandledCommand");

            case MessageTypeKind.ExecuteFailing:
                return("HandleFailingCommand");

            case MessageTypeKind.Distribute:
                return("DistributeMessage");

            case MessageTypeKind.Distributed:
                return("DistributedMessage");

            case MessageTypeKind.DistributeFailing:
                return("DistributeFailingMessage");

            case MessageTypeKind.LocalEvent:
                return("LocalEvent");

            case MessageTypeKind.ClientEvent:
                return("ClientEvent");

            default:
                throw new GeneralException("意外的命令类型");
            }
        }
Beispiel #11
0
            /// <summary>
            ///
            /// </summary>
            /// <param name="acDomain"></param>
            /// <param name="commandType"></param>
            /// <param name="record"></param>
            /// <returns></returns>
            internal static CommandRecord Create(IAcDomain acDomain, MessageTypeKind commandType, System.Data.IDataRecord record)
            {
                MessageType requestType;

                record.GetString(record.GetOrdinal("MessageType")).TryParse(out requestType);
                ClientType clientType;

                record.GetString(record.GetOrdinal("ClientType")).TryParse(out clientType);
                return(new CommandRecord(commandType,
                                         record.GetGuid(record.GetOrdinal("Id")),
                                         DataItemsTuple.Create(
                                             acDomain,
                                             record.GetNullableString("InfoId"),
                                             record.GetNullableString("InfoValue"),
                                             record.GetNullableString("QueryList"),
                                             record.GetString(record.GetOrdinal("InfoFormat"))))
                {
                    Verb = new Verb(record.GetString(record.GetOrdinal("Verb"))),
                    Ontology = record.GetString(record.GetOrdinal("Ontology")),
                    LocalEntityId = record.GetNullableString("LocalEntityId"),
                    CatalogCode = record.GetNullableString("CatalogCode"),
                    ClientId = record.GetString(record.GetOrdinal("ClientId")),
                    TimeStamp = record.GetDateTime(record.GetOrdinal("TimeStamp")),
                    ReceivedOn = record.GetDateTime(record.GetOrdinal("ReceivedOn")),
                    CreateOn = record.GetDateTime(record.GetOrdinal("CreateOn")),
                    ClientType = clientType,
                    MessageType = requestType,
                    MessageId = record.GetString(record.GetOrdinal("MessageId")),
                    Status = record.GetInt32(record.GetOrdinal("Status")),
                    ReasonPhrase = record.GetNullableString(record.GetOrdinal("ReasonPhrase")),
                    Description = record.GetNullableString(record.GetOrdinal("Description")),
                    EventSubjectCode = record.GetNullableString(record.GetOrdinal("EventSubjectCode")),
                    EventSourceType = record.GetNullableString(record.GetOrdinal("EventSourceType")),
                    UserName = record.GetNullableString("UserName"),
                    IsDumb = record.GetBoolean(record.GetOrdinal("IsDumb")),
                    Version = record.GetString(record.GetOrdinal("Version"))
                });
            }
Beispiel #12
0
        public MessageEntity GetCommand(MessageTypeKind commandType, OntologyDescriptor ontology, Guid id)
        {
            var db = this.GetCommandDb(ontology);
            var queryString =
            @"select * from " + GetTableName(commandType) + " as a where a.Id=@Id";
            using (var reader = db.ExecuteReader(queryString, CreateParameter(db, "Id", id, DbType.Guid)))
            {
                if (reader.Read())
                {
                    return CommandRecord.Create(ontology.Host, commandType, reader);
                }
            }

            return null;
        }
Beispiel #13
0
        /// <summary>
        /// 根据节点分页获取命令
        /// </summary>
        /// <typeparam name="T">命令类型参数</typeparam>
        /// <param name="commandType"></param>
        /// <param name="ontology">本体</param>
        /// <param name="catalogCode">目录码</param>
        /// <param name="actionCode">动作码,空值表示忽略本查询条件</param>
        /// <param name="nodeId">节点标识,空值表示忽略本查询条件</param>
        /// <param name="localEntityId">本地实体标识</param>
        /// <param name="pageIndex">页索引</param>
        /// <param name="pageSize">页尺寸</param>
        /// <param name="sortField">排序字段</param>
        /// <param name="sortOrder">排序方向</param>
        /// <param name="total">总记录数</param>
        /// <returns></returns>
        public IList <MessageEntity> GetPlistCommands(MessageTypeKind commandType,
                                                      OntologyDescriptor ontology, string catalogCode, string actionCode, Guid?nodeId, string localEntityId,
                                                      int pageIndex, int pageSize, string sortField, string sortOrder, out Int64 total)
        {
            var tableName   = GetTableName(commandType);
            var queryString =
                @"select top " + pageSize.ToString(CultureInfo.InvariantCulture) + " * from (SELECT ROW_NUMBER() OVER(ORDER BY " + sortField + " " + sortOrder + ") AS RowNumber,* from " + tableName +
                @" as a where a.Ontology=@Ontology {0}) b 
 where b.RowNumber>" + (pageSize * pageIndex).ToString(CultureInfo.InvariantCulture);
            var countQs =
                @"select count(Id) from " + tableName + @" as a 
where a.Ontology=@Ontology {0}";

            if (!string.IsNullOrEmpty(actionCode))
            {
                queryString = string.Format(queryString, " and a.Verb=@Verb {0}");
                countQs     = string.Format(countQs, " and a.Verb=@Verb {0}");
            }
            if (!string.IsNullOrEmpty(localEntityId))
            {
                queryString = string.Format(queryString, " and a.LocalEntityID=@LocalEntityId {0}");
                countQs     = string.Format(countQs, " and a.LocalEntityID=@LocalEntityId {0}");
            }
            if (!string.IsNullOrEmpty(catalogCode))
            {
                queryString = string.Format(queryString, " and a.CatalogCode like @CatalogCode {0}");
                countQs     = string.Format(countQs, " and a.CatalogCode like @CatalogCode {0}");
            }
            if (nodeId.HasValue)
            {
                queryString = string.Format(queryString, " and a.ClientID=@ClientId");
                countQs     = string.Format(countQs, " and a.ClientID=@ClientId");
            }
            else
            {
                queryString = string.Format(queryString, "");
                countQs     = string.Format(countQs, "");
            }
            var db    = this.GetCommandDb(ontology);
            var parms = new List <DbParameter> {
                CreateParameter(db, "Ontology", ontology.Ontology.Code, DbType.String)
            };

            if (!string.IsNullOrEmpty(actionCode))
            {
                parms.Add(CreateParameter(db, "Verb", actionCode, DbType.String));
            }
            if (nodeId.HasValue)
            {
                parms.Add(CreateParameter(db, "ClientId", nodeId.Value, DbType.Guid));
            }
            if (!string.IsNullOrEmpty(localEntityId))
            {
                parms.Add(CreateParameter(db, "LocalEntityId", localEntityId, DbType.String));
            }
            if (!string.IsNullOrEmpty(catalogCode))
            {
                parms.Add(CreateParameter(db, "CatalogCode", catalogCode + "%", DbType.String));
            }

            var pArray = parms.ToArray();
            IList <MessageEntity> list = new List <MessageEntity>();

            using (var reader = this.GetCommandDb(ontology).ExecuteReader(queryString, pArray))
            {
                while (reader.Read())
                {
                    list.Add(CommandRecord.Create(ontology.Host, commandType, reader));
                }
            }
            total = (int)this.GetCommandDb(ontology).ExecuteScalar(countQs, parms.Select(p => ((ICloneable)p).Clone()).Cast <DbParameter>().ToArray());

            return(list);
        }
Beispiel #14
0
        /// <summary>
        /// 根据节点分页获取命令
        /// </summary>
        /// <typeparam name="T">命令类型参数</typeparam>
        /// <param name="commandType"></param>
        /// <param name="ontology">本体</param>
        /// <param name="catalogCode">目录码</param>
        /// <param name="actionCode">动作码,空值表示忽略本查询条件</param>
        /// <param name="nodeId">节点标识,空值表示忽略本查询条件</param>
        /// <param name="localEntityId">本地实体标识</param>
        /// <param name="pageIndex">页索引</param>
        /// <param name="pageSize">页尺寸</param>
        /// <param name="sortField">排序字段</param>
        /// <param name="sortOrder">排序方向</param>
        /// <param name="total">总记录数</param>
        /// <returns></returns>
        public IList<MessageEntity> GetPlistCommands(MessageTypeKind commandType,
            OntologyDescriptor ontology, string catalogCode, string actionCode, Guid? nodeId, string localEntityId,
            int pageIndex, int pageSize, string sortField, string sortOrder, out Int64 total)
        {
            var tableName = GetTableName(commandType);
            var queryString =
            @"select top " + pageSize.ToString(CultureInfo.InvariantCulture) + " * from (SELECT ROW_NUMBER() OVER(ORDER BY " + sortField + " " + sortOrder + ") AS RowNumber,* from " + tableName +
            @" as a where a.Ontology=@Ontology {0}) b
             where b.RowNumber>" + (pageSize * pageIndex).ToString(CultureInfo.InvariantCulture);
            var countQs =
            @"select count(Id) from " + tableName + @" as a
            where a.Ontology=@Ontology {0}";
            if (!string.IsNullOrEmpty(actionCode))
            {
                queryString = string.Format(queryString, " and a.Verb=@Verb {0}");
                countQs = string.Format(countQs, " and a.Verb=@Verb {0}");
            }
            if (!string.IsNullOrEmpty(localEntityId))
            {
                queryString = string.Format(queryString, " and a.LocalEntityID=@LocalEntityId {0}");
                countQs = string.Format(countQs, " and a.LocalEntityID=@LocalEntityId {0}");
            }
            if (!string.IsNullOrEmpty(catalogCode))
            {
                queryString = string.Format(queryString, " and a.CatalogCode like @CatalogCode {0}");
                countQs = string.Format(countQs, " and a.CatalogCode like @CatalogCode {0}");
            }
            if (nodeId.HasValue)
            {
                queryString = string.Format(queryString, " and a.ClientID=@ClientId");
                countQs = string.Format(countQs, " and a.ClientID=@ClientId");
            }
            else
            {
                queryString = string.Format(queryString, "");
                countQs = string.Format(countQs, "");
            }
            var db = this.GetCommandDb(ontology);
            var parms = new List<DbParameter> { CreateParameter(db, "Ontology", ontology.Ontology.Code, DbType.String) };
            if (!string.IsNullOrEmpty(actionCode))
            {
                parms.Add(CreateParameter(db, "Verb", actionCode, DbType.String));
            }
            if (nodeId.HasValue)
            {
                parms.Add(CreateParameter(db, "ClientId", nodeId.Value, DbType.Guid));
            }
            if (!string.IsNullOrEmpty(localEntityId))
            {
                parms.Add(CreateParameter(db, "LocalEntityId", localEntityId, DbType.String));
            }
            if (!string.IsNullOrEmpty(catalogCode))
            {
                parms.Add(CreateParameter(db, "CatalogCode", catalogCode + "%", DbType.String));
            }

            var pArray = parms.ToArray();
            IList<MessageEntity> list = new List<MessageEntity>();
            using (var reader = this.GetCommandDb(ontology).ExecuteReader(queryString, pArray))
            {
                while (reader.Read())
                {
                    list.Add(CommandRecord.Create(ontology.Host, commandType, reader));
                }
            }
            total = (int)this.GetCommandDb(ontology).ExecuteScalar(countQs, parms.Select(p => ((ICloneable)p).Clone()).Cast<DbParameter>().ToArray());

            return list;
        }
Beispiel #15
0
        /// <summary>
        /// 获取给定条目的给定类型的命令
        /// </summary>
        /// <param name="commandType"></param>
        /// <param name="ontology"></param>
        /// <param name="n">条数</param>
        /// <param name="sortField"></param>
        /// <param name="sortOrder"></param>
        /// <returns>命令消息集合</returns>
        public IList<MessageEntity> GetTopNCommands(MessageTypeKind commandType, OntologyDescriptor ontology, int n, string sortField, string sortOrder)
        {
            if (ontology == null)
            {
                return new List<MessageEntity>();
            }
            if (commandType == MessageTypeKind.Invalid || commandType == MessageTypeKind.AnyCommand)
            {
                return new List<MessageEntity>();
            }
            var db = this.GetCommandDb(ontology);
            var sql =
            @"select top " + n.ToString(CultureInfo.InvariantCulture) +
            " * from [" + GetTableName(commandType) + "] as c where lower(c.Ontology)=@Ontology order by c." + sortField + " " + sortOrder;
            var pOntology = CreateParameter(db, "Ontology", ontology.Ontology.Code.ToLower(), DbType.String);
            IList<MessageEntity> list = new List<MessageEntity>();
            using (var reader = db.ExecuteReader(sql, pOntology))
            {
                while (reader.Read())
                {
                    list.Add(CommandRecord.Create(ontology.Host, commandType, reader));
                }
                reader.Close();

                return list;
            }
        }
Beispiel #16
0
 private string GetTableName(MessageTypeKind commandType)
 {
     switch (commandType)
     {
         case MessageTypeKind.Invalid:
             throw new AnycmdException("意外的命令类型");
         case MessageTypeKind.AnyCommand:
             throw new AnycmdException("AnyCommand不能持久化,没有TableName概念。");
         case MessageTypeKind.Received:
             return "ReceivedMessage";
         case MessageTypeKind.Unaccepted:
             return "UnacceptedMessage";
         case MessageTypeKind.Executed:
             return "HandledCommand";
         case MessageTypeKind.ExecuteFailing:
             return "HandleFailingCommand";
         case MessageTypeKind.Distribute:
             return "DistributeMessage";
         case MessageTypeKind.Distributed:
             return "DistributedMessage";
         case MessageTypeKind.DistributeFailing:
             return "DistributeFailingMessage";
         case MessageTypeKind.LocalEvent:
             return "LocalEvent";
         case MessageTypeKind.ClientEvent:
             return "ClientEvent";
         default:
             throw new AnycmdException("意外的命令类型");
     }
 }
Beispiel #17
0
        public ProcessResult DeleteCommand(MessageTypeKind commandType, OntologyDescriptor ontology, Guid id, bool isDumb)
        {
            ProcessResult r;
            if (isDumb)
            {
                r = ProcessResult.Ok;
            }
            else
            {
                var db = this.GetCommandDb(ontology);
                var queryString =
            @"delete " + GetTableName(commandType) + " where Id=@Id";
                int n = db.ExecuteNonQuery(queryString, CreateParameter(db, "Id", id, DbType.Guid));
                if (n == 1)
                {
                    r = ProcessResult.Ok;
                }
                else
                {
                    r = new ProcessResult(new AnycmdException("意外的影响行数" + n.ToString(CultureInfo.InvariantCulture)));
                }
            }

            if (r.Exception != null)
            {
                ontology.Host.LoggingService.Error(r.Exception);
            }

            return r;
        }
Beispiel #18
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="type"></param>
 /// <param name="dataTuple">数据项集合对</param>
 /// <param name="id">信息标识</param>
 private CommandRecord(MessageTypeKind type, Guid id, DataItemsTuple dataTuple)
     : base(type, id, dataTuple)
 {
 }
Beispiel #19
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="type"></param>
 /// <param name="dataTuple"></param>
 /// <param name = "responseNode"></param>
 private AnyMessage(MessageTypeKind type, DataItemsTuple dataTuple, NodeDescriptor responseNode)
     : this(type, Guid.NewGuid(), dataTuple, responseNode)
 {
 }
 /// <summary>
 /// 根据Id查询命令详细信息
 /// </summary>
 /// <typeparam name="T">命令详细信息展示模型类型参数</typeparam>
 /// <param name="messageProvider">命令提供程序</param>
 /// <param name="messageTypeKind"></param>
 /// <param name="ontology">本体</param>
 /// <param name="id">命令标识</param>
 /// <returns></returns>
 public static MessageTr GetCommandInfo(
     this IMessageProvider messageProvider, MessageTypeKind messageTypeKind, OntologyDescriptor ontology, Guid id)
 {
     var command = messageProvider.GetCommand(messageTypeKind, ontology, id);
     return MessageTr.Create(ontology.Host, command);
 }
Beispiel #21
0
 private MessageEntity ToEntity(MessageTypeKind commandType, QueryResult result)
 {
     if (commandType == MessageTypeKind.Invalid || commandType == MessageTypeKind.AnyCommand)
     {
         throw new AnycmdException("不能转化为Invalid或AnyCommand类型命令");
     }
     return new MessageEntity(commandType, this.Id, this.DataTuple)
     {
         Status = result.Status,
         ReasonPhrase = result.ReasonPhrase,
         Description = result.Description,
         CreateOn = DateTime.Now,
         Version = this.Version,
         IsDumb = this.IsDumb,
         Verb = this.Verb,
         ClientId = this.ClientId,
         ClientType = this.ClientType,
         EventSourceType = this.EventSourceType,
         EventSubjectCode = this.EventSubjectCode,
         UserName = this.UserName,
         Ontology = this.Ontology,
         ReceivedOn = this.ReceivedOn,
         MessageId = this.MessageId,
         MessageType = this.MessageType,
         LocalEntityId = this.LocalEntityId,
         CatalogCode = this.CatalogCode,
         TimeStamp = this.TimeStamp,
         From = this.From,
         RelatesTo = this.RelatesTo,
         SessionId = this.SessionId,
         To = this.To
     };
 }
Beispiel #22
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="type"></param>
 /// <param name="dataTuple">数据项集合对</param>
 /// <param name="id">信息标识</param>
 public MessageEntity(MessageTypeKind type, Guid id, DataItemsTuple dataTuple)
     : base(type, id, dataTuple)
 {
 }
Beispiel #23
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="type"></param>
 /// <param name="dataTuple">数据项集合对</param>
 /// <param name="id">信息标识</param>
 private CommandRecord(MessageTypeKind type, Guid id, DataItemsTuple dataTuple)
     : base(type, id, dataTuple)
 {
 }
Beispiel #24
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="acDomain"></param>
 /// <param name="commandType"></param>
 /// <param name="record"></param>
 /// <returns></returns>
 internal static CommandRecord Create(IAcDomain acDomain, MessageTypeKind commandType, System.Data.IDataRecord record)
 {
     MessageType requestType;
     record.GetString(record.GetOrdinal("MessageType")).TryParse(out requestType);
     ClientType clientType;
     record.GetString(record.GetOrdinal("ClientType")).TryParse(out clientType);
     return new CommandRecord(commandType,
         record.GetGuid(record.GetOrdinal("Id")),
         DataItemsTuple.Create(
             acDomain,
             record.GetNullableString("InfoId"),
             record.GetNullableString("InfoValue"),
             record.GetNullableString("QueryList"),
             record.GetString(record.GetOrdinal("InfoFormat"))))
             {
                 Verb = new Verb(record.GetString(record.GetOrdinal("Verb"))),
                 Ontology = record.GetString(record.GetOrdinal("Ontology")),
                 LocalEntityId = record.GetNullableString("LocalEntityId"),
                 CatalogCode = record.GetNullableString("CatalogCode"),
                 ClientId = record.GetString(record.GetOrdinal("ClientId")),
                 TimeStamp = record.GetDateTime(record.GetOrdinal("TimeStamp")),
                 ReceivedOn = record.GetDateTime(record.GetOrdinal("ReceivedOn")),
                 CreateOn = record.GetDateTime(record.GetOrdinal("CreateOn")),
                 ClientType = clientType,
                 MessageType = requestType,
                 MessageId = record.GetString(record.GetOrdinal("MessageId")),
                 Status = record.GetInt32(record.GetOrdinal("Status")),
                 ReasonPhrase = record.GetNullableString(record.GetOrdinal("ReasonPhrase")),
                 Description = record.GetNullableString(record.GetOrdinal("Description")),
                 EventSubjectCode = record.GetNullableString(record.GetOrdinal("EventSubjectCode")),
                 EventSourceType = record.GetNullableString(record.GetOrdinal("EventSourceType")),
                 UserName = record.GetNullableString("UserName"),
                 IsDumb = record.GetBoolean(record.GetOrdinal("IsDumb")),
                 Version = record.GetString(record.GetOrdinal("Version"))
             };
 }
Beispiel #25
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="type"></param>
 /// <param name="dataTuple">数据项集合对</param>
 /// <param name="id">信息标识</param>
 public MessageEntity(MessageTypeKind type, Guid id, DataItemsTuple dataTuple)
     : base(type, id, dataTuple)
 {
 }
Beispiel #26
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="type"></param>
 /// <param name="dataTuple"></param>
 /// <param name = "responseNode"></param>
 private AnyMessage(MessageTypeKind type, DataItemsTuple dataTuple, NodeDescriptor responseNode)
     : this(type, Guid.NewGuid(), dataTuple, responseNode)
 {
 }
Beispiel #27
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="type"></param>
 /// <param name="dataTuple">数据项集合对</param>
 /// <param name="id">信息标识</param>
 /// <param name = "responseNode"></param>
 private AnyMessage(MessageTypeKind type, Guid id, DataItemsTuple dataTuple, NodeDescriptor responseNode)
     : base(type, id, dataTuple)
 {
     this._responseNode = responseNode;
 }
Beispiel #28
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="type"></param>
 /// <param name="dataTuple">数据项集合对</param>
 /// <param name="id">信息标识</param>
 /// <param name = "responseNode"></param>
 private AnyMessage(MessageTypeKind type, Guid id, DataItemsTuple dataTuple, NodeDescriptor responseNode)
     : base(type, id, dataTuple)
 {
     this._responseNode = responseNode;
 }