Exemple #1
0
 public Rdbs(IAcDomain acDomain, IDbTables dbTables, IDbViews dbViews, IDbTableColumns dbTableColumns, IDbViewColumns dbViewColumns)
 {
     if (acDomain == null)
     {
         throw new ArgumentNullException("acDomain");
     }
     if (dbTables == null)
     {
         throw new ArgumentNullException("dbTables");
     }
     if (dbViews == null)
     {
         throw new ArgumentNullException("dbViews");
     }
     if (dbTableColumns == null)
     {
         throw new ArgumentNullException("dbTableColumns");
     }
     if (dbViewColumns == null)
     {
         throw new ArgumentNullException("dbViewColumns");
     }
     _acDomain = acDomain;
     _dbTables = dbTables;
     _dbViews = dbViews;
     _dbTableColumns = dbTableColumns;
     _dbViewColumns = dbViewColumns;
 }
 /// <summary>
 /// 命令分发上下文。单条命令
 /// </summary>
 /// <param name="command"></param>
 /// <param name = "responder"></param>
 public DistributeContext(MessageBase command, NodeDescriptor responder)
 {
     if (command == null)
     {
         throw new ArgumentNullException("command");
     }
     if (responder == null)
     {
         throw new ArgumentNullException("responder");
     }
     this._acDomain = responder.AcDomain;
     this.Command = command;
     this.Responder = responder;
     #region 如果是head命令类型去掉信息值以减小体积
     DataItem[] infoId = command.DataTuple.IdItems.Items;
     DataItem[] infoValue;
     // 使用ID映射字典转化ID,同时如果是head命令类型去掉信息值以减小体积
     if (Verb.Get.Equals(command.Verb)
         || Verb.Head.Equals(command.Verb))
     {
         infoValue = null;
     }
     else
     {
         infoValue = command.DataTuple.ValueItems.Items;
     }
     #endregion
     this.Result = new QueryResult(command);
 }
Exemple #3
0
 private AcSessionState(IAcDomain acDomain)
 {
     if (acDomain == null)
     {
         throw new ArgumentNullException("acDomain");
     }
 }
Exemple #4
0
 private DataItemsTuple(
     IAcDomain acDomain,
     DataItem[] dataIdItems, string idString,
     DataItem[] dataValueItems, string valueString,
     string[] getElement, string getElementString,
     string infoFormat)
 {
     this._acDomain = acDomain;
     if (dataIdItems == null && idString == null)
     {
         dataIdItems = new DataItem[0];
     }
     if (dataValueItems == null && valueString == null)
     {
         dataValueItems = new DataItem[0];
     }
     if (string.IsNullOrEmpty(infoFormat))
     {
         throw new AnycmdException("infoFormat不能为空");
     }
     if (!acDomain.NodeHost.InfoStringConverters.TryGetInfoStringConverter(infoFormat, out _converter))
     {
         throw new AnycmdException("意外的信息格式" + infoFormat);
     }
     this.InfoFormat = infoFormat;
     this.QueryList = getElement;
     this.QueryList = getElement;
     this.QueryListString = getElementString;
     this.IdItems = new DataItems(dataIdItems, idString, _converter);
     this.ValueItems = new DataItems(dataValueItems, valueString, _converter);
 }
Exemple #5
0
        static void Main(string[] args)
        {
            //程序没有运行
            try
            {
                EfContext.InitStorage(new SimpleEfContextStorage());
                // 环境初始化
                var acDomain = new DefaultAcDomain();
                _acDomain = acDomain;
                _acDomain.AddService(typeof(ILoggingService), new Log4NetLoggingService(_acDomain));
                _acDomain.AddService(typeof(IAcSessionStorage), new SimpleAcSessionStorage());
                acDomain.Init();
                _acDomain.RegisterRepository(new List<string> {
                        "EdiEntities",
                        "AcEntities",
                        "InfraEntities",
                        "IdentityEntities"
                    }, typeof(AcDomain).Assembly);

                Run(args);
            }
            catch (Exception ex)
            {
                _acDomain.LoggingService.Error(ex);
                Console.WriteLine(ex.Message);
                Console.WriteLine(@"按任意键退出");
                Console.ReadKey();
            }
        }
 public Log4NetLoggingService(IAcDomain acDomain)
 {
     GlobalContext.Properties["ProcessName"] = Process.GetCurrentProcess().ProcessName;
     GlobalContext.Properties["BaseDirectory"] = AppDomain.CurrentDomain.BaseDirectory;
     this._acDomain = acDomain;
     XmlConfigurator.ConfigureAndWatch(new FileInfo(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile));
     _log = LogManager.GetLogger(typeof(Log4NetLoggingService));
 }
Exemple #7
0
 public NodeDescriptor(IAcDomain acDomain, NodeState node)
 {
     this._acDomain = acDomain;
     if (node == null)
     {
         throw new ArgumentNullException("node");
     }
     this.Node = node;
 }
Exemple #8
0
 public ServiceHost(IAcDomain acDomain, string serviceName, params Assembly[] assembliesWithServices)
     : base(serviceName, assembliesWithServices)
 {
     if (acDomain == null)
     {
         throw new ArgumentNullException("acDomain");
     }
     this._acDomain = acDomain;
 }
Exemple #9
0
 /// <summary>
 /// Initializes a new instance of your ServiceStack application, with the specified name and assembly containing the services.
 /// </summary>
 public ServiceHost(IAcDomain acDomain)
     : base("数据交换服务", typeof(MessageService).Assembly)
 {
     if (acDomain == null)
     {
         throw new ArgumentNullException("acDomain");
     }
     this._acDomain = acDomain;
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="process"></param>
 public DefaultDispatcher(ProcessDescriptor process)
 {
     if (process == null)
     {
         throw new ArgumentNullException("process");
     }
     this._acDomain = process.AcDomain;
     this.Process = process;
     this.Ontology = process.Ontology;
 }
Exemple #11
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="acDomain"></param>
 /// <param name="command"></param>
 /// <exception cref="ArgumentNullException"></exception>
 public MessageContext(IAcDomain acDomain, MessageBase command)
 {
     if (command == null)
     {
         this.Exception = new ArgumentNullException("command");
         throw this.Exception;
     }
     this._acDomain = acDomain;
     this.Command = command;
     this.Result = new QueryResult(command) {ResultDataItems = new List<DataItem>()};
 }
Exemple #12
0
 public StateCodeSet(IAcDomain acDomain)
 {
     if (acDomain == null)
     {
         throw new ArgumentNullException("acDomain");
     }
     if (acDomain.Equals(EmptyAcDomain.SingleInstance))
     {
         _initialized = true;
     }
     this._acDomain = acDomain;
 }
Exemple #13
0
 internal AcSessionState(IAcDomain acDomain, IAcSessionEntity acSessionEntity)
     : this(acDomain)
 {
     if (acSessionEntity == null)
     {
         throw new ArgumentNullException("acSessionEntity");
     }
     Identity = new AnycmdIdentity(acSessionEntity.LoginName);
     _acDomain = acDomain;
     _id = acSessionEntity.Id;
     _accountId = acSessionEntity.AccountId;
 }
 /// <summary>
 /// 构造并接入总线
 /// </summary>
 internal InfoStringConverterSet(IAcDomain acDomain)
 {
     if (acDomain == null)
     {
         throw new ArgumentNullException("acDomain");
     }
     if (acDomain.Equals(EmptyAcDomain.SingleInstance))
     {
         _initialized = true;
     }
     this._acDomain = acDomain;
 }
Exemple #15
0
 public static MenuMiniNode Create(IAcDomain acDomain, IMenu menu)
 {
     return(new MenuMiniNode(acDomain)
     {
         Id = menu.Id,
         expanded = false,
         img = menu.Icon,
         Name = menu.Name,
         ParentId = menu.ParentId,
         SortCode = menu.SortCode,
         Url = menu.Url
     });
 }
 /// <summary>
 /// Initializes a new instance of <c>MongoDBRepository[TAggregateRoot]</c> class.
 /// </summary>
 /// <param name="acDomain"></param>
 /// <param name="context">The <see cref="IRepositoryContext"/> object for initializing the current repository.</param>
 public MongoDbRepository(IAcDomain acDomain, IMongoDbRepositoryContext context)
 {
     if (acDomain == null)
     {
         throw new ArgumentNullException("acDomain");
     }
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     _acDomain = acDomain;
     _context  = context;
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="acDomain"></param>
 public static void RegisterEdiCore(this IAcDomain acDomain)
 {
     #region Edi
     acDomain.AddService(typeof(IExecutorFactory), new ExecutorFactory());
     acDomain.AddService(typeof(IDispatcherFactory), new DispatcherFactory());
     acDomain.AddService(typeof(IAuthenticator), new DefaultAuthenticator());
     acDomain.AddService(typeof(IMessageProducer), new DefaultMessageProducer());
     acDomain.AddService(typeof(IStackTraceFormater), new JsonStackTraceFormater());
     acDomain.AddService(typeof(IInputValidator), new DefaultInputValidator());
     acDomain.AddService(typeof(IAuditDiscriminator), new DefaultAuditDiscriminator());
     acDomain.AddService(typeof(IPermissionValidator), new DefaultPermissionValidator());
     #endregion
 }
Exemple #18
0
        public static UiViewState Create(IAcDomain acDomain, UiViewBase view)
        {
            if (view == null)
            {
                throw new ArgumentNullException("view");
            }

            return(new UiViewState(view.Id)
            {
                _acDomain = acDomain,
                _createOn = view.CreateOn
            }.InternalModify(view));
        }
Exemple #19
0
 internal ButtonSet(IAcDomain acDomain)
 {
     if (acDomain == null)
     {
         throw new ArgumentNullException("acDomain");
     }
     if (acDomain.Equals(EmptyAcDomain.SingleInstance))
     {
         _initialized = true;
     }
     _acDomain = acDomain;
     new MessageHandler(this).Register();
 }
        private IAcSession GetAcSessionByLoginName(IAcDomain acDomain, string loginName)
        {
            if (EmptyAcDomain.SingleInstance.Equals(acDomain))
            {
                return(AcSessionState.Empty);
            }
            var storage   = acDomain.GetRequiredService <IAcSessionStorage>();
            var acSession = storage.GetData(acDomain.Config.CurrentAcSessionCacheKey) as IAcSession;

            if (acSession != null)
            {
                return(acSession);
            }
            var account = AcSessionState.AcMethod.GetAccountByLoginName(acDomain, loginName);

            if (account == null)
            {
                return(AcSessionState.Empty);
            }
            var sessionEntity = AcSessionState.AcMethod.GetAcSessionEntity(acDomain, account.Id);

            if (sessionEntity != null)
            {
                if (!sessionEntity.IsAuthenticated)
                {
                    return(AcSessionState.Empty);
                }
                acSession = new AcSessionState(acDomain, sessionEntity);
            }
            else
            {
                // 使用账户标识作为会话标识会导致一个账户只有一个会话
                // TODO:支持账户和会话的一对多,为会话级的动态责任分离做准备
                var accountState    = AccountState.Create(account);
                var identity        = new AnycmdIdentity(account.LoginName);
                var acSessionEntity = new AcSession
                {
                    Id                 = account.Id,
                    AccountId          = account.Id,
                    AuthenticationType = identity.AuthenticationType,
                    Description        = null,
                    IsAuthenticated    = identity.IsAuthenticated,
                    IsEnabled          = 1,
                    LoginName          = account.LoginName
                };
                AcSessionState.AcMethod.AddAcSession(acDomain, acSessionEntity);
                acSession = new AcSessionState(acDomain, account.Id, accountState);
            }
            storage.SetData(acDomain.Config.CurrentAcSessionCacheKey, acSession);
            return(acSession);
        }
Exemple #21
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="acDomain"></param>
        /// <param name="context"></param>
        public static MessageContext Create(IAcDomain acDomain, HecpContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            var commandContext = new MessageContext(acDomain, AnyMessage.Create(context.Request, acDomain.NodeHost.Nodes.ThisNode));

            foreach (var act in context)
            {
                commandContext.Trace(act);
            }
            return(commandContext);
        }
Exemple #22
0
 public static InfoRuleTr Create(IAcDomain acDomain, InfoRuleState infoRule)
 {
     return new InfoRuleTr
     {
         Id = infoRule.Id,
         Author = infoRule.InfoRule.Author,
         Description = infoRule.InfoRule.Description,
         FullName = infoRule.InfoRule.GetType().Name,
         Name = infoRule.InfoRule.Name,
         Title = infoRule.InfoRule.Title,
         CreateOn = infoRule.CreateOn,
         IsEnabled = infoRule.IsEnabled
     };
 }
Exemple #23
0
 public static InfoRuleTr Create(IAcDomain acDomain, InfoRuleState infoRule)
 {
     return(new InfoRuleTr
     {
         Id = infoRule.Id,
         Author = infoRule.InfoRule.Author,
         Description = infoRule.InfoRule.Description,
         FullName = infoRule.InfoRule.GetType().Name,
         Name = infoRule.InfoRule.Name,
         Title = infoRule.InfoRule.Title,
         CreateOn = infoRule.CreateOn,
         IsEnabled = infoRule.IsEnabled
     });
 }
Exemple #24
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="acDomain"></param>
 /// <param name="command"></param>
 /// <exception cref="ArgumentNullException"></exception>
 public MessageContext(IAcDomain acDomain, MessageBase command)
 {
     if (command == null)
     {
         this.Exception = new ArgumentNullException("command");
         throw this.Exception;
     }
     this._acDomain = acDomain;
     this.Command   = command;
     this.Result    = new QueryResult(command)
     {
         ResultDataItems = new List <DataItem>()
     };
 }
Exemple #25
0
        public static NodeOntologyCatalogState Create(IAcDomain acDomain, INodeOntologyCatalog nodeOntologyOrg)
        {
            if (nodeOntologyOrg == null)
            {
                throw new ArgumentNullException("nodeOntologyOrg");
            }
            var data = new NodeOntologyCatalogState(acDomain, nodeOntologyOrg.Id)
            {
                Actions    = nodeOntologyOrg.Actions,
                NodeId     = nodeOntologyOrg.NodeId,
                OntologyId = nodeOntologyOrg.OntologyId,
                CatalogId  = nodeOntologyOrg.CatalogId
            };
            var nodeOrgActionDic = new Dictionary <Verb, INodeCatalogAction>();

            data._nodeOrgActionDic = nodeOrgActionDic;
            if (data.Actions != null)
            {
                var nodeOrgActions = acDomain.JsonSerializer.Deserialize <NodeCatalogAction[]>(data.Actions);
                if (nodeOrgActions != null)
                {
                    foreach (var orgAction in nodeOrgActions)
                    {
                        var action = acDomain.NodeHost.Ontologies.GetAction(orgAction.ActionId);
                        if (action == null)
                        {
                            throw new AnycmdException("意外的目录动作标识" + orgAction.ActionId);
                        }
                        OntologyDescriptor ontology;
                        if (!acDomain.NodeHost.Ontologies.TryGetOntology(action.OntologyId, out ontology))
                        {
                            throw new AnycmdException("意外的本体元素本体标识" + action.OntologyId);
                        }
                        CatalogState org;
                        if (!acDomain.CatalogSet.TryGetCatalog(orgAction.CatalogId, out org))
                        {
                            throw new AnycmdException("意外的目录动作目录标识" + orgAction.CatalogId);
                        }
                        var actionDic = acDomain.NodeHost.Ontologies.GetActons(ontology);
                        var verb      = actionDic.Where(a => a.Value.Id == orgAction.ActionId).Select(a => a.Key).FirstOrDefault();
                        if (verb == null)
                        {
                            throw new AnycmdException("意外的本体动作标识" + orgAction.ActionId);
                        }
                        nodeOrgActionDic.Add(verb, orgAction);
                    }
                }
            }
            return(data);
        }
 private IAccount GetAccount(IAcDomain acDomain, string loginName)
 {
     if (EmptyAcDomain.SingleInstance.Equals(acDomain))
     {
         return(null);
     }
     using (var conn = GetAccountDb(acDomain).GetConnection())
     {
         if (conn.State != ConnectionState.Open)
         {
             conn.Open();
         }
         return(conn.Query <Account>("select * from [Account] where LoginName=@LoginName", new { LoginName = loginName }).FirstOrDefault());
     }
 }
Exemple #27
0
 public DefaultNodeHost(IAcDomain acDomain)
 {
     this.StateCodes           = new StateCodeSet(acDomain);
     this.HecpHandler          = new HecpHandler();
     this.MessageProducer      = new DefaultMessageProducer();
     this.Ontologies           = new OntologySet(acDomain);
     this.Processs             = new ProcesseSet(acDomain);
     this.Nodes                = new NodeSet(acDomain);
     this.InfoDics             = new InfoDicSet(acDomain);
     this.InfoStringConverters = new InfoStringConverterSet(acDomain);
     this.InfoRules            = new InfoRuleSet(acDomain);
     this.MessageProviders     = new MessageProviderSet(acDomain);
     this.EntityProviders      = new EntityProviderSet(acDomain);
     this.Transfers            = new MessageTransferSet(acDomain);
 }
 private void DoUpdateAcSession(IAcDomain acDomain, IAcSessionEntity acSessionEntity)
 {
     if (EmptyAcDomain.SingleInstance.Equals(acDomain))
     {
         return;
     }
     using (var conn = GetAccountDb(acDomain).GetConnection())
     {
         if (conn.State != ConnectionState.Open)
         {
             conn.Open();
         }
         conn.Execute("update AcSession set IsAuthenticated=@IsAuthenticated where Id=@Id", new { acSessionEntity.IsAuthenticated, acSessionEntity.Id });
     }
 }
 private IAccount GetAccount(IAcDomain acDomain, Guid accountId)
 {
     if (EmptyAcDomain.SingleInstance.Equals(acDomain))
     {
         return(null);
     }
     using (var conn = GetAccountDb(acDomain).GetConnection())
     {
         if (conn.State != ConnectionState.Open)
         {
             conn.Open();
         }
         return(conn.Query <Account>("select * from [Account] where Id=@Id", new { Id = accountId }).FirstOrDefault());
     }
 }
 private void OnSignOuted(IAcDomain acDomain, Guid sessionId)
 {
     if (EmptyAcDomain.SingleInstance.Equals(acDomain))
     {
         return;
     }
     using (var conn = GetAccountDb(acDomain).GetConnection())
     {
         if (conn.State != ConnectionState.Open)
         {
             conn.Open();
         }
         conn.Execute("update AcSession set IsAuthenticated=@IsAuthenticated where Id=@Id", new { IsAuthenticated = false, Id = sessionId });
     }
 }
Exemple #31
0
 public ServiceSelfHost(Anycmd.IAcDomain acDomain, ProcessDescriptor process)
     : base("Self-Host", typeof(MessageService).Assembly)
 {
     if (acDomain == null)
     {
         throw new ArgumentNullException("acDomain");
     }
     if (process == null)
     {
         throw new ArgumentNullException("process");
     }
     this._acDomain   = acDomain;
     this._process    = process;
     this.ServiceName = process.ProcessType.ToName() + " - " + process.Process.Name;
 }
Exemple #32
0
 public DefaultNodeHost(IAcDomain acDomain)
 {
     this.StateCodes = new StateCodeSet(acDomain);
     this.HecpHandler = new HecpHandler();
     this.MessageProducer = new DefaultMessageProducer();
     this.Ontologies = new OntologySet(acDomain);
     this.Processs = new ProcesseSet(acDomain);
     this.Nodes = new NodeSet(acDomain);
     this.InfoDics = new InfoDicSet(acDomain);
     this.InfoStringConverters = new InfoStringConverterSet(acDomain);
     this.InfoRules = new InfoRuleSet(acDomain);
     this.MessageProviders = new MessageProviderSet(acDomain);
     this.EntityProviders = new EntityProviderSet(acDomain);
     this.Transfers = new MessageTransferSet(acDomain);
 }
Exemple #33
0
 public PluginInfo(IAcDomain acDomain, Dictionary <string, object> dic)
 {
     if (dic == null)
     {
         throw new ArgumentNullException("dic");
     }
     foreach (var item in dic)
     {
         this.Add(item.Key, item.Value);
     }
     if (!this.ContainsKey("IsEnabledName"))
     {
         this.Add("IsEnabledName", acDomain.Translate("Edi", "InfoDic", "IsEnabledName", (int)this["IsEnabled"]));
     }
 }
 private void DoDeleteAcSession(IAcDomain acDomain, Guid sessionId)
 {
     if (EmptyAcDomain.SingleInstance.Equals(acDomain))
     {
         return;
     }
     using (var conn = GetAccountDb(acDomain).GetConnection())
     {
         if (conn.State != ConnectionState.Open)
         {
             conn.Open();
         }
         conn.Execute("delete AcSession where Id=@Id", new { Id = sessionId });
     }
 }
Exemple #35
0
 public ServiceSelfHost(Anycmd.IAcDomain acDomain, ProcessDescriptor process)
     : base("Self-Host", typeof(MessageService).Assembly)
 {
     if (acDomain == null)
     {
         throw new ArgumentNullException("acDomain");
     }
     if (process == null)
     {
         throw new ArgumentNullException("process");
     }
     this._acDomain = acDomain;
     this._process = process;
     this.ServiceName = process.ProcessType.ToName() + " - " + process.Process.Name;
 }
Exemple #36
0
 public static AppSystemTr Create(IAcDomain acDomain, AppSystemState appSystem)
 {
     return(new AppSystemTr(acDomain)
     {
         Code = appSystem.Code,
         CreateOn = appSystem.CreateOn,
         Icon = appSystem.Icon,
         Id = appSystem.Id,
         IsEnabled = appSystem.IsEnabled,
         Name = appSystem.Name,
         PrincipalId = appSystem.PrincipalId,
         SortCode = appSystem.SortCode,
         SsoAuthAddress = appSystem.SsoAuthAddress
     });
 }
Exemple #37
0
        public static Mock <TRepository> GetMoqRepository <TEntity, TRepository>(this IAcDomain acDomain)
            where TEntity : class, IAggregateRoot
            where TRepository : class, IRepository <TEntity>
        {
            var moRepository = new Mock <TRepository>();
            var context      = new MoqRepositoryContext(acDomain);

            moRepository.Setup(a => a.Context).Returns(context);
            moRepository.Setup(a => a.Add(It.IsAny <TEntity>()));
            moRepository.Setup(a => a.Remove(It.IsAny <TEntity>()));
            moRepository.Setup(a => a.Update(It.IsAny <TEntity>()));
            moRepository.Setup(a => a.GetByKey(It.IsAny <Guid>())).Returns((TEntity)null);
            moRepository.Setup(a => a.AsQueryable()).Returns(new List <TEntity>().AsQueryable());

            return(moRepository);
        }
Exemple #38
0
 public static CatalogState Create(IAcDomain acDomain, CatalogBase catalog)
 {
     if (acDomain == null)
     {
         throw new ArgumentNullException("acDomain");
     }
     if (catalog == null)
     {
         throw new ArgumentNullException("catalog");
     }
     return(new CatalogState(catalog.Id)
     {
         _acDomain = acDomain,
         _createOn = catalog.CreateOn
     }.InternalModify(catalog));
 }
        private RdbDescriptor GetAccountDb(IAcDomain acDomain)
        {
            EntityTypeState entityType;

            if (!acDomain.EntityTypeSet.TryGetEntityType(new Coder("Ac", "Account"), out entityType))
            {
                throw new AnycmdException("意外的实体类型码Ac.Account");
            }
            RdbDescriptor db;

            if (!acDomain.Rdbs.TryDb(entityType.DatabaseId, out db))
            {
                throw new AnycmdException("意外的账户数据库标识" + entityType.DatabaseId);
            }
            return(db);
        }
Exemple #40
0
 public static FunctionState Create(IAcDomain acDomain, FunctionBase function)
 {
     if (acDomain == null)
     {
         throw new ArgumentNullException("acDomain");
     }
     if (function == null)
     {
         throw new ArgumentNullException("function");
     }
     return(new FunctionState(function.Id)
     {
         _acDomain = acDomain,
         _createOn = function.CreateOn
     }.InternalModify(function));
 }
Exemple #41
0
 public static InfoDicState Create(IAcDomain acDomain, IInfoDic infoDic)
 {
     if (infoDic == null)
     {
         throw new ArgumentNullException("infoDic");
     }
     return(new InfoDicState(infoDic.Id)
     {
         AcDomain = acDomain,
         Code = infoDic.Code,
         CreateOn = infoDic.CreateOn,
         IsEnabled = infoDic.IsEnabled,
         Name = infoDic.Name,
         SortCode = infoDic.SortCode
     });
 }
Exemple #42
0
 public static TopicState Create(IAcDomain acDomain, ITopic topic)
 {
     if (topic == null)
     {
         throw new ArgumentNullException("topic");
     }
     return(new TopicState(acDomain, topic.Id)
     {
         Code = topic.Code,
         CreateOn = topic.CreateOn,
         Description = topic.Description,
         IsAllowed = topic.IsAllowed,
         Name = topic.Name,
         OntologyId = topic.OntologyId
     });
 }
Exemple #43
0
 /// <summary>
 /// Initializes a new instance of the <c>RdbmsDomainEventStorage&lt;TRdbmsStorage&gt;</c> class.
 /// </summary>
 /// <param name="acDomain"></param>
 /// <param name="connectionString">The connection string which is used when connecting
 /// to the relational database system. For more information about the connection strings
 /// for different database providers, please refer to http://www.connectionstrings.com.
 /// </param>
 /// <param name="mappingResolver">The instance of the mapping resolver which resolves the table and column mappings
 /// between data objects and the relational database system.</param>
 protected RdbmsDomainEventStorage(IAcDomain acDomain, string connectionString, IStorageMappingResolver mappingResolver)
 {
     try
     {
         this._acDomain         = acDomain;
         this._connectionString = connectionString;
         this._mappingResolver  = mappingResolver;
         Type storageType = typeof(TRdbmsStorage);
         _storage = (TRdbmsStorage)Activator.CreateInstance(storageType, new object[] { connectionString, mappingResolver });
     }
     catch
     {
         GC.SuppressFinalize(this);
         throw;
     }
 }
        private static void AddService(IAcDomain acDomain, List <EfRepositoryContext> repositoryContexts, Type aggregateRootType, Type sourceIdType)
        {
            var repositoryType   = typeof(GenericRepository <,>);
            var genericInterface = typeof(IRepository <,>);

            repositoryType   = repositoryType.MakeGenericType(aggregateRootType, sourceIdType);
            genericInterface = genericInterface.MakeGenericType(aggregateRootType, sourceIdType);
            foreach (var repositoryContext in repositoryContexts)
            {
                if (TryGetType(repositoryContext, aggregateRootType))
                {
                    var repository = Activator.CreateInstance(repositoryType, acDomain, repositoryContext.EfDbContextName);
                    acDomain.AddService(genericInterface, repository);
                }
            }
        }
Exemple #45
0
        private static void DeleteAcSession(IAcDomain acDomain, Guid acSessionId)
        {
            if (EmptyAcDomain.SingleInstance.Equals(acDomain))
            {
                return;
            }
            var repository = acDomain.GetRequiredService <IRepository <AcSession, Guid> >();
            var entity     = repository.GetByKey(acSessionId);

            if (entity == null)
            {
                return;
            }
            repository.Remove(entity);
            repository.Context.Commit();
        }
Exemple #46
0
 public static AppSystemState Create(IAcDomain acDomain, AppSystemBase appSystem)
 {
     if (acDomain == null)
     {
         throw new ArgumentNullException("acDomain");
     }
     if (appSystem == null)
     {
         throw new ArgumentNullException("appSystem");
     }
     return(new AppSystemState(appSystem.Id)
     {
         _acDomain = acDomain,
         _createOn = appSystem.CreateOn
     }.InternalModify(appSystem));
 }
Exemple #47
0
        private static void OnSignOuted(IAcDomain acDomain, Guid sessionId)
        {
            if (EmptyAcDomain.SingleInstance.Equals(acDomain))
            {
                return;
            }
            var repository = acDomain.GetRequiredService <IRepository <AcSession, Guid> >();
            var entity     = repository.GetByKey(sessionId);

            if (entity == null)
            {
                return;
            }
            entity.IsAuthenticated = false;
            repository.Update(entity);
        }
Exemple #48
0
 /// <summary>
 /// 构造并接入总线
 /// </summary>
 internal InfoRuleSet(IAcDomain acDomain)
 {
     if (acDomain == null)
     {
         throw new ArgumentNullException("acDomain");
     }
     if (acDomain.Equals(EmptyAcDomain.SingleInstance))
     {
         _initialized = true;
     }
     this._acDomain = acDomain;
     var messageDispatcher = acDomain.MessageDispatcher;
     if (messageDispatcher == null)
     {
         throw new ArgumentNullException("AcDomain对象'{0}'尚未设置MessageDispatcher。".Fmt(acDomain.Name));
     }
 }
 private static void Register(IAcDomain acDomain, string endsWith, params Assembly[] assemblies)
 {
     foreach (var assembly in assemblies)
     {
         foreach (var type in assembly.GetTypes())
         {
             if (type.IsClass && type.Name.EndsWith(endsWith))
             {
                 var defaultInterface = type.GetInterface("I" + type.Name);
                 if (defaultInterface != null)
                 {
                     acDomain.AddService(defaultInterface, Activator.CreateInstance(type, acDomain));
                 }
             }
         }
     }
 }
Exemple #50
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="acDomain"></param>
 /// <param name="database"></param>
 public RdbDescriptor(IAcDomain acDomain, IRDatabase database)
 {
     if (database == null)
     {
         throw new ArgumentNullException("database");
     }
     if (acDomain == null)
     {
         throw new ArgumentNullException("acDomain");
     }
     _acDomain = acDomain;
     CatalogState rdbmsType;
     if (!_acDomain.CatalogSet.TryGetCatalog(database.RdbmsType, out rdbmsType))
     {
         throw new AnycmdException("意外的关系数据库类型" + database.RdbmsType);
     }
     this.Database = database;
 }
Exemple #51
0
 internal AcSessionState(IAcDomain acDomain, Guid sessionId, AccountState account)
     : this(acDomain)
 {
     if (account == null)
     {
         throw new ArgumentNullException("account");
     }
     if (account == AccountState.Empty)
     {
         Identity = new UnauthenticatedIdentity();
     }
     else
     {
         Identity = new AnycmdIdentity(account.LoginName);
     }
     _acDomain = acDomain;
     _id = sessionId;
     _account = account;
     _accountId = account.Id;
 }
Exemple #52
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="acDomain"></param>
 /// <param name="request"></param>
 public HecpContext(IAcDomain acDomain, HecpRequest request)
 {
     if (acDomain == null)
     {
         throw new ArgumentNullException("acDomain");
     }
     this.Request = request;
     this._acDomain = acDomain;
     if (request == null)
     {
         _isValidated = true;
         _isValid = false;
         this.Response = HecpResponse.Create(string.Empty);
         this.Response.UpdateStatus(Status.InvalidArgument, "请求参数为null");
     }
     else
     {
         this.Response = HecpResponse.Create(request.MessageId);
     }
 }
Exemple #53
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="acDomain"></param>
 /// <param name="acts"></param>
 /// <param name="actor"></param>
 /// <param name="name"></param>
 public WfAct(IAcDomain acDomain, IStackTrace acts, IWfResource actor, string name)
 {
     if (actor == null)
     {
         throw new ArgumentNullException("actor");
     }
     if (acDomain == null)
     {
         throw new ArgumentNullException("acDomain");
     }
     this._acDomain = acDomain;
     if (acDomain.Config.TraceIsEnabled)
     {
         this.ActorId = actor.Id;
         this.ActorName = actor.Name;
         this.ActorType = actor.BuiltInResourceKind.ToName();
         this.ActingOn = DateTime.Now;
         this.Name = name;
         acts.Trace(this);
     }
 }
Exemple #54
0
        /// <summary>
        ///     Used to get the current NHibernate session associated with a factory key; i.e., the key 
        ///     associated with an NHibernate session factory for a specific database.
        /// </summary>
        public static RdbContext CreateDbContext(IAcDomain acDomain, string efDbContextName)
        {
            if (string.IsNullOrEmpty(efDbContextName))
            {
                throw new ArgumentNullException(efDbContextName, @"objectContextKey may not be null or empty");
            }
            // alert:这里有个约定
            Engine.Rdb.RdbDescriptor db;
            string databaseKey = efDbContextName + "DatabaseId";
            Guid databaseId;
            if (!Guid.TryParse(ConfigurationManager.AppSettings[databaseKey], out databaseId))
            {
                throw new AnycmdException("DatabaseId应是Guid格式");
            }
            if (!acDomain.Rdbs.TryDb(databaseId, out db))
            {
                throw new AnycmdException("意外的" + databaseKey + ":" + databaseId);
            }
            var efDbContext = new RdbContext(db,
                string.Format(ConfigurationManager.ConnectionStrings[efDbContextName].ConnectionString, db.ConnString));

            return efDbContext;
        }
Exemple #55
0
 private HecpRequest(IAcDomain acDomain, IMessageDto cmdDto)
     : this(acDomain)
 {
     if (cmdDto == null)
     {
         throw new ArgumentNullException("cmdDto");
     }
     if (cmdDto.Body == null)
     {
         throw new AnycmdException();
     }
     this._message = cmdDto;
     if (cmdDto.Body.InfoId == null)
     {
         _infoId = new DataItem[0];
     }
     if (cmdDto.Body.InfoValue == null)
     {
         _infoValue = new DataItem[0];
     }
     if (cmdDto.Body.InfoId != null)
     {
         _infoId = cmdDto.Body.InfoId.Where(a => a != null).Select(a => new DataItem(a.Key, a.Value)).ToArray();
     }
     if (cmdDto.Body.InfoValue != null)
     {
         _infoValue = cmdDto.Body.InfoValue.Where(a => a != null).Select(a => new DataItem(a.Key, a.Value)).ToArray();
     }
     this._queryList = cmdDto.Body.QueryList;
     this.Credential = new CredentialObject(cmdDto.Credential);
     this._verb = new Verb(cmdDto.Verb);
     if (cmdDto.Body.Event == null) return;
     _eventSourceType = cmdDto.Body.Event.SourceType;
     _eventSubject = cmdDto.Body.Event.Subject;
     _eventStatus = cmdDto.Body.Event.Status;
     _eventReasonPhrase = cmdDto.Body.Event.ReasonPhrase;
 }
Exemple #56
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="acDomain"></param>
 /// <param name="batch"></param>
 public BatchDescriptor(IAcDomain acDomain, IBatch batch)
 {
     if (batch == null)
     {
         throw new ArgumentNullException("batch");
     }
     this._batch = batch;
     OntologyDescriptor ontology;
     if (!acDomain.NodeHost.Ontologies.TryGetOntology(batch.OntologyId, out ontology))
     {
         throw new AnycmdException("意外的本体标识" + batch.OntologyId);
     }
     this.Ontology = ontology;
     NodeDescriptor node;
     if (!acDomain.NodeHost.Nodes.TryGetNodeById(batch.NodeId.ToString(), out node))
     {
         throw new AnycmdException("意外的节点标识" + batch.NodeId);
     }
     this.Node = node;
     if (!batch.Type.TryParse(out _batchType))
     {
         throw new AnycmdException("意外的批类型" + batch.Type);
     }
 }
Exemple #57
0
 public DbViewColumns(IAcDomain acDomain)
 {
     this._acDomain = acDomain;
     // TODO:接入总线
 }
Exemple #58
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="acDomain"></param>
 /// <param name="cmdDto"></param>
 /// <returns></returns>
 public static HecpRequest Create(IAcDomain acDomain, IMessageDto cmdDto)
 {
     return cmdDto == null ? null : new HecpRequest(acDomain, cmdDto);
 }
Exemple #59
0
 private HecpRequest(IAcDomain acDomain)
 {
     this._acDomain = acDomain;
 }
Exemple #60
0
 private NodeTr(IAcDomain acDomain)
 {
     this._acDomain = acDomain;
 }