public bool Import(Guid solutionId, List <Domain.QueryView> queryViews) { if (queryViews.NotEmpty()) { foreach (var item in queryViews) { var entity = _queryViewFinder.FindById(item.QueryViewId); if (entity != null) { entity.Description = item.Description; entity.FetchConfig = item.FetchConfig; entity.IsDefault = item.IsDefault; entity.StateCode = item.StateCode; entity.LayoutConfig = item.LayoutConfig; entity.IsCustomButton = item.IsCustomButton; entity.CustomButtons = item.CustomButtons; entity.TargetFormId = item.TargetFormId; entity.ModifiedBy = _appContext.GetFeature <ICurrentUser>().SystemUserId; entity.ModifiedOn = DateTime.Now; entity.Name = item.Name; _queryViewUpdater.Update(entity); } else { item.SolutionId = solutionId; item.ComponentState = 0; item.CreatedBy = _appContext.GetFeature <ICurrentUser>().SystemUserId; item.CreatedOn = DateTime.Now; _queryViewCreater.Create(item); } } } return(true); }
public DefaultAttributeProvider(IAppContext appContext , IAttributeFinder attributeFinder) { _appContext = appContext; _attributeFinder = attributeFinder; _loc = _appContext.GetFeature <ILocalizedTextProvider>(); _currentUser = _appContext.GetFeature <ICurrentUser>(); }
public bool Import(Guid solutionId, IList <Domain.OptionSet> optionSets) { if (optionSets.NotEmpty()) { foreach (var item in optionSets) { foreach (var d in item.Items) { d.OptionSetId = item.OptionSetId; } var entity = _optionSetFinder.FindById(item.OptionSetId); if (entity != null) { item.CreatedBy = _appContext.GetFeature <ICurrentUser>().SystemUserId; item.CreatedOn = DateTime.Now; item.SolutionId = solutionId; item.OrganizationId = _appContext.OrganizationId; _optionSetUpdater.Update(item); //_optionSetDetailService.DeleteByParentId(entity.OptionSetId); //_optionSetDetailService.CreateMany(item.Items); foreach (var d in item.Items) { var dd = _optionSetDetailFinder.Find(x => x.OptionSetId == item.OptionSetId && x.OptionSetDetailId == d.OptionSetDetailId); if (dd != null) { dd.Name = d.Name; dd.Value = d.Value; _optionSetDetailUpdater.Update(dd); } else { d.OptionSetId = item.OptionSetId; _optionSetDetailCreater.Create(d); } } } else { item.CreatedBy = _appContext.GetFeature <ICurrentUser>().SystemUserId; item.CreatedOn = DateTime.Now; item.SolutionId = solutionId; item.OrganizationId = _appContext.GetFeature <ICurrentUser>().OrganizationId; _optionSetCreater.Create(item); _optionSetDetailCreater.CreateMany(item.Items); } } } return(true); }
public UserVariableReplacer(IAppContext appContext , IBusinessUnitService businessUnitService) { _appContext = appContext; _currentUser = _appContext.GetFeature <ICurrentUser>(); _businessUnitService = businessUnitService; }
public bool Import(Guid solutionId, IList <EntityMapXmlInfo> entityMaps) { if (entityMaps.NotEmpty()) { foreach (var item in entityMaps) { var entity = _entityMapFinder.FindById(item.EntityMapId); if (entity != null) { _entityMapUpdater.Update(item); if (item.AttributeMaps.NotEmpty()) { _attributeMapDeleter.DeleteByParentId(entity.EntityMapId); _attributeMapCreater.CreateMany(item.AttributeMaps); } } else { item.CreatedBy = _appContext.GetFeature <ICurrentUser>().SystemUserId; item.SolutionId = solutionId; item.ComponentState = 0; item.CreatedOn = DateTime.Now; _entityMapCreater.Create(item); } } } return(true); }
public bool Update(Chart entity) { entity.ModifiedBy = _appContext.GetFeature <ICurrentUser>().SystemUserId; entity.ModifiedOn = DateTime.Now; var result = _chartRepository.Update(entity); if (result) { //依赖 _dependencyService.Update(entity); //localization _localizedLabelService.Update(entity.Name.IfEmpty(""), "LocalizedName", entity.ChartId, _appContext.BaseLanguage); _localizedLabelService.Update(entity.Description.IfEmpty(""), "Description", entity.ChartId, _appContext.BaseLanguage); } return(result); }
public bool Import(Guid solutionId, IList <Domain.Entity> entities) { if (entities.NotEmpty()) { foreach (var item in entities) { var existEntity = _entityFinder.FindById(item.EntityId); if (existEntity != null) { existEntity.DuplicateEnabled = item.DuplicateEnabled; existEntity.AuthorizationEnabled = item.AuthorizationEnabled; existEntity.LogEnabled = item.LogEnabled; existEntity.LocalizedName = item.LocalizedName; existEntity.BusinessFlowEnabled = item.BusinessFlowEnabled; existEntity.WorkFlowEnabled = item.WorkFlowEnabled; _entityUpdater.Update(existEntity); } else { item.SolutionId = solutionId; item.ComponentState = 0; item.CreatedBy = _appContext.GetFeature <ICurrentUser>().SystemUserId; item.CreatedOn = DateTime.Now; item.IsCustomizable = true; item.OrganizationId = _appContext.OrganizationId; _entityCreater.Create(item, false); } //字段 _attributeImporter.Import(solutionId, item, item.Attributes); } } return(true); }
public bool Create(LogLevel logLevel, string title, string description = "") { var entity = new Domain.VisitedLog(); entity.LogLevel = logLevel; entity.Title = title; entity.Url = _appContext.HttpContext.GetThisPageUrl(); entity.UrlReferrer = _appContext.HttpContext.GetUrlReferrer(); entity.SystemUserId = _appContext.GetFeature <Identity.ICurrentUser>().SystemUserId; entity.StatusCode = _appContext.HttpContext.Response.StatusCode; entity.Description = description; entity.ClientIP = _appContext.HttpContext.GetClientIpAddress(); entity.CreatedOn = DateTime.Now; entity.OrganizationId = _appContext.GetFeature <Identity.ICurrentUser>().OrganizationId; return(Create(entity)); }
public EntityLogService(IAppContext appContext , IEntityLogRepository entityLogRepository) { _appContext = appContext; _currentUser = _appContext.GetFeature <ICurrentUser>(); _entityLogRepository = entityLogRepository; }
public bool Import(Guid solutionId, List <RibbonButtonXmlInfo> ribbonButtons) { if (ribbonButtons.NotEmpty()) { foreach (var item in ribbonButtons) { var entity = _ribbonButtonFinder.FindById(item.RibbonButtonId); if (entity != null) { entity.CssClass = item.CssClass; entity.DisplayOrder = item.DisplayOrder; entity.Icon = item.Icon; entity.JsAction = item.JsAction; entity.JsLibrary = item.JsLibrary; entity.Label = item.Label; entity.ShowArea = item.ShowArea; entity.StateCode = item.StateCode; _ribbonButtonUpdater.Update(entity); } else { item.SolutionId = solutionId; item.ComponentState = 0; item.CreatedBy = _appContext.GetFeature <ICurrentUser>().SystemUserId; item.CreatedOn = DateTime.Now; _ribbonButtonCreater.Create(item); } } } return(true); }
public bool Import(Guid solutionId, IList <Chart> charts) { if (charts.NotEmpty()) { foreach (var item in charts) { var entity = _chartFinder.FindById(item.ChartId); if (entity != null) { entity.DataConfig = item.DataConfig; entity.Description = item.Description; entity.Name = item.Name; entity.PresentationConfig = item.PresentationConfig; entity.StateCode = item.StateCode; _chartUpdater.Update(entity); } else { item.SolutionId = solutionId; item.ComponentState = 0; item.CreatedBy = _appContext.GetFeature <ICurrentUser>().SystemUserId; item.OrganizationId = _appContext.OrganizationId; _chartCreater.Create(item); } } } return(true); }
public bool Import(Guid solutionId, IList <EntityPlugin> entityPlugins) { if (entityPlugins.NotEmpty()) { foreach (var item in entityPlugins) { var entity = _entityPluginFinder.FindById(item.EntityPluginId); if (entity != null) { entity.AssemblyName = item.AssemblyName; entity.ClassName = item.ClassName; entity.EventName = item.EventName; entity.ProcessOrder = item.ProcessOrder; entity.TypeCode = item.TypeCode; _entityPluginUpdater.Update(entity); } else { item.SolutionId = solutionId; item.ComponentState = 0; item.CreatedBy = _appContext.GetFeature <ICurrentUser>().SystemUserId; item.CreatedOn = DateTime.Now; _entityPluginCreater.Create(item); } } } return(true); }
public bool Import(Guid solutionId, IList <Domain.Report> reports) { if (reports.NotEmpty()) { foreach (var item in reports) { var entity = _reportService.FindById(item.ReportId); if (entity != null) { entity.DefaultFilterConfig = item.DefaultFilterConfig; entity.CustomConfig = item.CustomConfig; entity.QueryConfig = item.QueryConfig; entity.BodyText = item.BodyText; entity.BodyUrl = item.BodyUrl; entity.FileName = item.FileName; entity.TypeCode = item.TypeCode; entity.EntityId = item.EntityId; entity.RelatedEntityId = item.RelatedEntityId; entity.Description = item.Description; entity.Name = item.Name; _reportService.Update(entity); } else { item.ComponentState = 0; item.SolutionId = solutionId; item.CreatedBy = _appContext.GetFeature <ICurrentUser>().SystemUserId; _reportService.Create(item); } } } return(true); }
public WorkflowStartedNotify(IAppContext appContext , IEnumerable <INotify> notifies) { _appContext = appContext; _loc = _appContext.GetFeature <ILocalizedTextProvider>(); _notifies = notifies; }
public WorkFlowCanceller(IAppContext appContext , IWorkFlowInstanceService WorkFlowInstanceService , IWorkFlowProcessUpdater workFlowProcessUpdater , IWorkFlowProcessFinder workFlowProcessFinder , IEventPublisher eventPublisher , ILogService logService) { _appContext = appContext; _loc = _appContext.GetFeature <ILocalizedTextProvider>(); _user = _appContext.GetFeature <ICurrentUser>(); _WorkFlowInstanceService = WorkFlowInstanceService; _workFlowProcessUpdater = workFlowProcessUpdater; _workFlowProcessFinder = workFlowProcessFinder; _eventPublisher = eventPublisher; _logService = logService; }
public bool Import(Guid solutionId, IList <DuplicateRule> duplicateRules) { if (duplicateRules.NotEmpty()) { foreach (var item in duplicateRules) { var entity = _duplicateRuleFinder.FindById(item.DuplicateRuleId); if (entity != null) { _duplicateRuleUpdater.Update(item); if (item.Conditions.NotEmpty()) { _duplicateRuleConditionService.DeleteByParentId(entity.DuplicateRuleId); foreach (var cnd in item.Conditions) { cnd.DuplicateRuleId = item.DuplicateRuleId; } _duplicateRuleConditionService.CreateMany(item.Conditions); } } else { item.CreatedBy = _appContext.GetFeature <ICurrentUser>().SystemUserId; item.SolutionId = solutionId; item.ComponentState = 0; item.CreatedOn = DateTime.Now; _duplicateRuleCreater.Create(item); } } } return(true); }
public bool Import(Guid solutionId, IList <Domain.WebResource> webResources) { if (webResources.NotEmpty()) { foreach (var item in webResources) { var entity = _webResourceFinder.FindById(item.WebResourceId, false); if (entity != null) { entity.Content = item.Content; entity.Description = item.Description; entity.Name = item.Name; _webResourceUpdater.Update(entity); } else { item.ComponentState = 0; item.SolutionId = solutionId; item.CreatedBy = _appContext.GetFeature <ICurrentUser>().SystemUserId; item.OrganizationId = _appContext.OrganizationId; _webResourceCreater.Create(item); } } } return(true); }
public bool Import(Guid solutionId, IList <SerialNumberRule> serialNumberRules) { if (serialNumberRules.NotEmpty()) { foreach (var item in serialNumberRules) { var entity = _serialNumberRuleFinder.FindById(item.SerialNumberRuleId); if (entity != null) { entity.DateFormatType = item.DateFormatType; entity.Description = item.Description; entity.Increment = item.Increment; entity.IncrementLength = item.IncrementLength; entity.Name = item.Name; entity.Prefix = item.Prefix; entity.Seprator = item.Seprator; entity.StateCode = item.StateCode; _serialNumberRuleUpdater.Update(entity); } else { item.CreatedBy = _appContext.GetFeature <ICurrentUser>().SystemUserId; item.SolutionId = solutionId; item.ComponentState = 0; item.CreatedOn = DateTime.Now; item.OrganizationId = _appContext.OrganizationId; _serialNumberRuleCreater.Create(item); } } } return(true); }
/// <summary> /// 删除记录 /// </summary> /// <param name="entityId">关联实体id</param> /// <param name="objectId">关联记录id</param> /// <returns></returns> public virtual bool DeleteById(Guid entityId, Guid objectId) { //查询 var query = new QueryExpression("attachment", _appContext.GetFeature <ICurrentUser>().UserSettings.LanguageId); query.ColumnSet.AddColumns("attachmentid", "cdnpath"); query.Criteria.AddCondition("entityid", ConditionOperator.Equal, entityId); query.Criteria.AddCondition("objectid", ConditionOperator.Equal, objectId); var entities = _dataFinder.RetrieveAll(query); var result = false; if (entities.NotEmpty()) { result = _dataDeleter.Delete("attachment", entities.Select(x => x.GetIdValue()).ToList()); if (result) { //delete files foreach (var item in entities) { var cdnPath = item.GetStringValue("cdnpath"); if (cdnPath.IsNotEmpty() && System.IO.File.Exists(_webHelper.MapPath(cdnPath))) { System.IO.File.Delete(_webHelper.MapPath(cdnPath)); } } } } return(result); }
public WorkFlowHandlerFinder(IAppContext appContext , IDataFinder dataFinder) { _appContext = appContext; _currentUser = _appContext.GetFeature <ICurrentUser>(); _dataFinder = dataFinder; }
public DefaultSystemFormProvider(IAppContext appContext , IDefaultAttributeProvider defaultAttributeProvider) { _defaultAttributeProvider = defaultAttributeProvider; _appContext = appContext; _loc = _appContext.GetFeature <ILocalizedTextProvider>(); }
public List <Guid> Authorized(string objectTypeName, params Guid[] objectId) { List <Guid> result = new List <Guid>(); if (objectId.IsEmpty()) { return(result); } int objectTypeCode = ModuleCollection.GetIdentity(objectTypeName); var resourceOwner = _resourceOwnerService.FindByName(objectTypeName); if (resourceOwner == null || resourceOwner.StateCode == Core.RecordState.Disabled) { return(result); } var userInRole = _appContext.GetFeature <ICurrentUser>().Roles.Select(f => f.RoleId).ToArray(); if (userInRole.NotEmpty()) { var roaList = _roleObjectAccessRepository.Query(x => x.RoleId.In(userInRole) && x.ObjectTypeCode == objectTypeCode && x.ObjectId.In(objectId)); result = objectId.ToList(); result.RemoveAll(x => !roaList.Exists(r => r.ObjectId == x)); return(result); } return(result); }
public SettingService(IAppContext appContext , ISettingRepository settingRepository) { _appContext = appContext; _currentUser = _appContext.GetFeature <ICurrentUser>(); _settingRepository = settingRepository; _cache = new CacheManager <Setting>($"{_appContext.OrganizationUniqueName}:settings", SettingCache.BuildKey); }
public LocalizedLabelService(IAppContext appContext , ILocalizedLabelRepository localizedLabelRepository ) { _appContext = appContext; _user = _appContext.GetFeature <ICurrentUser>(); _localizedLabelRepository = localizedLabelRepository; }
public WorkflowExecutedNotify(IAppContext appContext , IDataFinder dataFinder , IEnumerable <INotify> notifies) { _appContext = appContext; _loc = _appContext.GetFeature <ILocalizedTextProvider>(); _dataFinder = dataFinder; _notifies = notifies; }
/// <summary> /// 检测并抛出异常(如果存在依赖) /// </summary> /// <typeparam name="TRequired">被依赖对象类型</typeparam> /// <param name="requiredComponentType">被依赖组件类型</param> /// <param name="requiredId">被依赖对象主键</param> public void CheckAndThrow <TRequired>(int requiredComponentType, Guid requiredId) { var dependentComponents = _dependencyFinderFactory.GetDependents(requiredComponentType, requiredId); if (dependentComponents.NotEmpty()) { throw new XmsDependencyException(_appContext.GetFeature <ILocalizedTextProvider>()["referenced"], dependentComponents); } }
/// <summary> /// 重复规则命中 /// </summary> /// <param name="organizationService"></param> /// <param name="data"></param> /// <param name="entityMetadata"></param> /// <param name="attributeMetadatas"></param> /// <returns></returns> public virtual IEnumerable <DuplicateRuleHitResult> ExecuteCore(Entity data, Schema.Domain.Entity entityMetadata, List <Schema.Domain.Attribute> attributeMetadatas) { if (!entityMetadata.DuplicateEnabled) { yield break; } var duplicateRules = _duplicateRuleFinder.QueryByEntityId(entityMetadata.EntityId, RecordState.Enabled); if (duplicateRules.NotEmpty()) { var languageId = _appContext.GetFeature <ICurrentUser>().UserSettings.LanguageId; foreach (var rule in duplicateRules) { rule.Conditions = _duplicateRuleConditionService.Query(n => n.Where(w => w.DuplicateRuleId == rule.DuplicateRuleId)); var attrid = rule.Conditions.Select(s => s.AttributeId).ToArray(); var attributes = attributeMetadatas.Where(w => attrid.Contains(w.AttributeId)); QueryExpression qe = new QueryExpression(data.Name, languageId); qe.AddColumns(attributes.Select(s => s.Name).ToArray()); FilterExpression filter = new FilterExpression(LogicalOperator.And); foreach (var item in qe.ColumnSet.Columns) { if (!data.ContainsKey(item)) { continue; } var attr = attributeMetadatas.Find(n => n.Name.IsCaseInsensitiveEqual(item)); object value = data.UnWrapAttributeValue(attr); //忽略空值 if (rule.Conditions.Find(x => x.AttributeId == attr.AttributeId).IgnoreNullValues) { if (value == null || value.ToString().IsEmpty()) { continue; } } filter.AddCondition(item, ConditionOperator.NotNull); filter.AddCondition(item, ConditionOperator.Equal, value); } if (filter.Conditions.NotEmpty() && data.ContainsKey(data.IdName)) { //排除自身的比较 filter.AddCondition(data.IdName, ConditionOperator.NotEqual, data.GetIdValue()); } if (filter.Conditions.NotEmpty()) { qe.Criteria.AddFilter(filter); var record = _dataFinder.Retrieve(qe, true); if (record != null && record.Count > 0) { yield return(new DuplicateRuleHitResult { Rule = rule, Target = record }); } } } } }
public QueryByAttributeResolver(IAppContext appContext , IDbContext dbContext , IQueryMetadataFinder queryMetadataFinder) { this.User = appContext.GetFeature <ICurrentUser>(); _dbContext = dbContext; _repository = new DataRepositoryBase <dynamic>(_dbContext); _queryMetadataFinder = queryMetadataFinder; }
public SystemFormFinder(IAppContext appContext , ISystemFormRepository systemFormRepository , IRoleObjectAccessService roleObjectAccessService) { _appContext = appContext; _currentUser = _appContext.GetFeature <ICurrentUser>(); _systemFormRepository = systemFormRepository; _roleObjectAccessService = roleObjectAccessService; _cacheService = new Caching.CacheManager <Domain.SystemForm>(_appContext.OrganizationUniqueName + ":systemforms", _appContext.PlatformSettings.CacheEnabled); }
public DataProviderBase( IAppContext appContext , IEntityFinder entityFinder , IRoleObjectAccessEntityPermissionService roleObjectAccessEntityPermissionService , IPrincipalObjectAccessService principalObjectAccessService , IEventPublisher eventPublisher , IBusinessUnitService businessUnitService ) { _appContext = appContext; _user = _appContext.GetFeature <ICurrentUser>(); _languageId = _user?.UserSettings?.LanguageId ?? LanguageCode.CHS; _loc = _appContext.GetFeature <ILocalizedTextProvider>(); _entityFinder = entityFinder; _roleObjectAccessEntityPermissionService = roleObjectAccessEntityPermissionService; _principalObjectAccessService = principalObjectAccessService; _businessUnitService = businessUnitService; _eventPublisher = eventPublisher; }