public EntityHistoryAppService( IRepository <Person, Guid> personRepository, IDynamicRepository dynamicRepository, IRepository <EntityHistoryEvent, Guid> eventRepository, IRepository <EntityChangeSet, long> entityChangeSetRepository, IRepository <EntityChange, long> entityChangeRepository, IRepository <EntityPropertyChange, long> entityPropertyChangeRepository, IRepository <EntityHistoryItem, long> entityHistoryItemRepository, IRepository <Setting, long> settingRepository, IObjectMapper mapper, ITypeFinder typeFinder, ISessionFactory sessionFactory) { PersonRepository = personRepository; DynamicRepository = dynamicRepository; EventRepository = eventRepository; EntityChangeSetRepository = entityChangeSetRepository; EntityPropertyChangeRepository = entityPropertyChangeRepository; EntityChangeRepository = entityChangeRepository; EntityHistoryItemRepository = entityHistoryItemRepository; _settingRepository = settingRepository; Mapper = mapper; TypeFinder = typeFinder; SessionFactory = sessionFactory; }
public FillController(IConfiguration configuration, IPdfFormMapRepository pdfFormRepository, IDynamicRepository dynamicRepository) { _pdfFilesOptions = configuration.GetSection("PdfFiles").Get <PdfFilesOptions>(); _pdfFormRepository = pdfFormRepository; _dynamicRepository = dynamicRepository; }
private void GetExtraColumns <TId, TUId>(IDynamicRepository repository, List <LookupObject <TId, TUId> > lookupCollection, List <DbColumn> columns, string lookupName, bool includeDeleted, List <FilterSearchCriteria> filters = null) where TId : IEquatable <TId> where TUId : struct { // Get Lookup object properties var properties = typeof(LookupObject <TId, TUId>).GetProperties(); StringBuilder extraQuery = new StringBuilder(); // Get extra Columns List <DbColumn> extraColumns = columns.Where(col => !properties.Any(prop => prop.Name == col.Name)).ToList(); // If there are extra columns if (extraColumns != null && extraColumns.Count > 0) { // Join all columns name seprated by , string columnStr = string.Join(",", extraColumns.Select(col => col.Name)); extraQuery.Append($"SELECT Id, {columnStr} FROM dbo.LK_{lookupName} AS E"); // Apply filter on extra query ApplyFilters <TUId>(extraQuery, includeDeleted, columns.Any(col => col.Name.ToLower() == LookUpConsts.CreatedByField.ToLower()), filters, columns); // Build dynmic type TypeBuilder builder = DynmicTypeBuilder.CreateTypeBuilder("MyDynmicAssembly", "MyModule", "MyType"); // Find Id Column DbColumn idColumn = columns.First(x => x.Name.ToLower() == LookUpConsts.IdField.ToLower()); // If id not exist if (idColumn == null) { throw new Exception("Can not find Id column for lookup entity."); } // Add id property. DynmicTypeBuilder.CreateAutoImplementedProperty(builder, idColumn.Name, idColumn.ColumnType); // Add columns as propreties at dynmic type. extraColumns.ForEach(col => DynmicTypeBuilder.CreateAutoImplementedProperty(builder, col.Name, col.ColumnType)); // Create Type of builder. Type resultType = builder.CreateType(); List <dynamic> extraFields = repository.ExecuteQuery(resultType, extraQuery.ToString()); foreach (var item in lookupCollection) { var dynmicObject = extraFields.FirstOrDefault(x => item.Id == x.Id); item.ExtraFields = new Dictionary <string, object>(); extraColumns.ForEach(col => { item.ExtraFields.Add(col.Name, resultType.GetProperty(col.Name).GetValue(dynmicObject)); }); } } }
public TaskManagementRelationAppService(IRepository <TaskManagementRelation, Guid> repository, WorkFlowCacheManager workFlowCacheManager, IDynamicRepository dynamicRepository, WorkFlowBusinessTaskManager workFlowBusinessTaskManager ) { this._repository = repository; _workFlowCacheManager = workFlowCacheManager; _dynamicRepository = dynamicRepository; _workFlowBusinessTaskManager = workFlowBusinessTaskManager; }
public AccountantCourseAppService(IRepository <AccountantCourse, Guid> repository, IDynamicRepository dynamicRepository , IHostingEnvironment env ) { this._repository = repository; //_abpFileRelationAppService = abpFileRelationAppService; hostingEnv = env; _appConfiguration = AppConfigurations.Get(env.ContentRootPath, env.EnvironmentName, env.IsDevelopment()); _dynamicRepository = dynamicRepository; }
public StoredFileController(IRepository <StoredFile, Guid> fileRepository, IRepository <StoredFileVersion, Guid> fileVersionRepository, IStoredFileService fileService, IDynamicRepository dynamicRepository, IUnitOfWorkManager unitOfWorkManager) { _fileService = fileService; _fileRepository = fileRepository; _fileVersionRepository = fileVersionRepository; _dynamicRepository = dynamicRepository; _unitOfWorkManager = unitOfWorkManager; }
public DynamicControllerManager(HttpRequestBase request, ControllerManager controllerManager, IDynamicRepository dynamicRepository, UrlHelper urlHelper) { RequestManager = new RequestManager(request); DynamicEntitySearcher = new DynamicEntitySearcher(RequestManager); RequestManager.QueryStringDictionary = RequestManager.QueryStringDictionary.RouteValueDictionaryTypeCorrection(DynamicEntitySearcher.DynamicEntityMetadata); ControllerManager = controllerManager; DynamicRepository = dynamicRepository; UrlManager = new UrlManager(urlHelper); ReturnUrlCalculator = new ReturnUrlCalculator(UrlManager); }
public DynamicControllerManager(HttpRequestBase request, ControllerManager controllerManager, IDynamicRepository dynamicRepository, UrlHelper urlHelper) { RequestManager = new RequestManager(request); DynamicEntitySearcher = new DynamicEntitySearcher(RequestManager); RequestManager.QueryStringDictionary = RequestManager.QueryStringDictionary.RouteValueDictionaryTypeCorrection(DynamicEntitySearcher.DynamicEntityMetadata); ControllerManager = controllerManager; DynamicRepository = dynamicRepository; UrlManager = new UrlManager(urlHelper); ReturnUrlCalculator = new ReturnUrlCalculator(UrlManager); }
public DynamicPropertyManager( IRepository <EntityProperty, Guid> entityPropertyRepository, IRepository <EntityPropertyValue, Guid> entityPropertyValueRepository, IEntityConfigurationStore entityConfigurationStore, IDynamicRepository dynamicRepository ) { _entityPropertyRepository = entityPropertyRepository; _entityPropertyValueRepository = entityPropertyValueRepository; _entityConfigurationStore = entityConfigurationStore; _dynamicRepository = dynamicRepository; }
public ProjectTodoAppService(IRepository <WorkFlowOrganizationUnits, long> workFlowOrganizationUnitsRepository, IRepository <WorkFlowUserOrganizationUnits, long> userOrganizationUnitRepository , IProjectBaseRepository projectBaseRepository, IRepository <ConstructionOrganizations> constructionOrganizationRepository, IRepository <ProjectAuditMember, Guid> projectAuditMemberRepository , IRepository <UserFollowProject, Guid> userFollowProjectRepository, IRepository <User, long> userrepository, IDynamicRepository dynamicRepository) { _projectBaseRepository = projectBaseRepository; _workFlowOrganizationUnitsRepository = workFlowOrganizationUnitsRepository; _userOrganizationUnitRepository = userOrganizationUnitRepository; _constructionOrganizationRepository = constructionOrganizationRepository; _projectAuditMemberRepository = projectAuditMemberRepository; _userFollowProjectRepository = userFollowProjectRepository; _userrepository = userrepository; _dynamicRepository = dynamicRepository; }
public static void Apply <T>(this IDynamicRepository <T> repo, QueryDescriptor descriptor, QueryParams queryParams) where T : class, new() { repo.ResetOriginQuery(); var rules = new List <string>(); rules.AddRange(descriptor.DefaultQueryRules); if (queryParams.Folder != null && descriptor.AcceptQueryRule(queryParams.Folder)) { rules.Add(queryParams.Folder); } repo.ApplyQueryRules(rules.ToArray()); }
public DynamicControllerBase(IDynamicRepository dynamicRepository, IRequestManager requestManager, IDynamicEntitySearchManager dynamicEntitySearchManager, IReturnUrlManager returnUrlManager, IDynamicIndexViewModelBuilder dynamicIndexViewModelBuilder, IDynamicCreateViewModelBuilder dynamicCreateViewModelBuilder, IDynamicEditViewModelBuilder dynamicEditViewModelBuilder, IDynamicDeleteViewModelBuilder dynamicDeleteViewModelBuilder, IDynamicDetailsViewModelBuilder dynamicDetailsViewModelBuilder, IDynamicIndexPageViewModelBuilder dynamicIndexPageViewModelBuilder) { _dynamicRepository = dynamicRepository; _requestManager = requestManager; _dynamicEntitySearchManager = dynamicEntitySearchManager; _returnUrlManager = returnUrlManager; _dynamicIndexViewModelBuilder = dynamicIndexViewModelBuilder; DynamicCreateViewModelBuilder = dynamicCreateViewModelBuilder; DynamicEditViewModelBuilder = dynamicEditViewModelBuilder; _dynamicDeleteViewModelBuilder = dynamicDeleteViewModelBuilder; DynamicDetailsViewModelBuilder = dynamicDetailsViewModelBuilder; DynamicIndexPageViewModelBuilder = dynamicIndexPageViewModelBuilder; }
private static void AddMemberRoots(IDynamicRepository repository, AggregateRootDefine define, DynamicRoot root) { var memberRoots = root.GetRoots(); foreach (var member in memberRoots) { var id = member.GetIdentity(); //为了防止死锁,我们开启的是不带锁的模式判定是否有本地数据 //虽然这有可能造成重复输入的插入而导致报错,但是几率非常低,而且不会引起灾难性bug var local = repository.Find(define, id, QueryLevel.None); if (local.IsEmpty()) { repository.Add(define, member); } } }
public CWGLBorrowMoneyAppService(IRepository <CWGLBorrowMoney, Guid> repository , WorkFlowBusinessTaskManager workFlowBusinessTaskManager, IAbpFileRelationAppService abpFileRelationAppService, ProjectAuditManager projectAuditManager, WorkFlowCacheManager workFlowCacheManager, IRepository <WorkFlowOrganizationUnits, long> organizationUnitRepository, IUnitOfWorkManager unitOfWorkManager, IRepository <User, long> usersRepository, IWorkFlowTaskRepository workFlowTaskRepository, IDynamicRepository dynamicRepository ) { _dynamicRepository = dynamicRepository; _workFlowCacheManager = workFlowCacheManager; this._repository = repository; _workFlowBusinessTaskManager = workFlowBusinessTaskManager; _abpFileRelationAppService = abpFileRelationAppService; _projectAuditManager = projectAuditManager; _unitOfWorkManager = unitOfWorkManager; _usersRepository = usersRepository; _organizationUnitRepository = organizationUnitRepository; _workFlowTaskRepository = workFlowTaskRepository; }
public WorkFlowTemplateAppService(IRepository <WorkFlowTemplate, Guid> workFlowTemplateRepository, IRepository <User, long> userRepository, IRepository <WorkFlowModel, Guid> workFlowModelRepository, IHostingEnvironment hostingEnv, IHttpContextAccessor accessor, IRepository <WorkFlowModelColumn, Guid> workFlowModelColumnRepository, IRepository <WorkFlowTemplateLog, Guid> workFlowTemplateLogRepository, IDynamicRepository dynamicRepository, WorkFlowCacheManager workFlowCacheManager ) { _workFlowTemplateRepository = workFlowTemplateRepository; _workFlowModelRepository = workFlowModelRepository; _workFlowModelColumnRepository = workFlowModelColumnRepository; _dynamicRepository = dynamicRepository; _workFlowCacheManager = workFlowCacheManager; _hostingEnv = hostingEnv; _userRepository = userRepository; _accessor = accessor; _workFlowTemplateLogRepository = workFlowTemplateLogRepository; }
public WorkTempAppService(WorkFlowOrganizationUnitsManager workFlowOrganizationUnitsManager , IRepository <UserPosts, Guid> userPostRepository, IRepository <PostInfo, Guid> postInfoRepository, WorkFlowBusinessTaskManager workFlowBusinessTaskManager , IRepository <WorkFlowOrganizationUnits, long> organizationUnitRepository, IRepository <WorkFlowUserOrganizationUnits, long> userOrganizationUnitRepository , IUnitOfWorkManager unitOfWorkManager, IRepository <ProjectAudit, Guid> projectAuditRepository, ProjectAuditManager projectAuditManager , WorkFlowCacheManager workFlowCacheManager, IWorkFlowTaskRepository workFlowTaskRepository, IDynamicRepository dynamicRepository, IHostingEnvironment env) { _workFlowOrganizationUnitsManager = workFlowOrganizationUnitsManager; _userPostRepository = userPostRepository; _postInfoRepository = postInfoRepository; _workFlowBusinessTaskManager = workFlowBusinessTaskManager; _organizationUnitRepository = organizationUnitRepository; _userOrganizationUnitRepository = userOrganizationUnitRepository; _unitOfWorkManager = unitOfWorkManager; _projectAuditRepository = projectAuditRepository; _projectAuditManager = projectAuditManager; _workFlowCacheManager = workFlowCacheManager; _workFlowTaskRepository = workFlowTaskRepository; _dynamicRepository = dynamicRepository; _appConfiguration = AppConfigurations.Get(env.ContentRootPath, env.EnvironmentName, env.IsDevelopment()); }
public static Dictionary <string, object> SetComplexValue(object value, ColumnSchema attribute, ObjectId tenantId, ObjectId userId, string roleCode, IDynamicRepository dynamicRepository, IDynamicService <DynamicRecord> dynamicService, ISchemaService schemaService) { var complexAttributeView = schemaService.GetView(attribute.DataType, ViewCategory.Create, tenantId, roleCode); //TODO: gutierfe. I think it should be .Catalog. var complexAttributeSchema = complexAttributeView.Schemas[attribute.DataType]; var isValid = true; //Create complex field value var fieldValue = new Dictionary <string, object>() { { complexAttributeSchema.UniqueIndex.Count() == 1 ? complexAttributeSchema.UniqueIndex.First() : attribute.ComplexFieldName, value } }; //assumming it has only one unique index, otherwise, use complex value field var dynamicRecordValue = new DynamicRecord().Initialize <DynamicRecord>(fieldValue as Dictionary <string, object>, null, ViewCategory.Catalog); ThrowExceptionIfViewIsNull(complexAttributeView); var id = ControllerHelper.FindExisting(dynamicRecordValue, complexAttributeView, tenantId, userId, dynamicService, out isValid); if (id != ObjectId.Empty) { dynamicRecordValue = dynamicRepository.Get <DynamicRecord>(attribute.DataType, id, tenantId); } return(dynamicRecordValue.Values()); }
public DynamicRepository(IModelDescriptorCollection descriptors, IServiceProvider serviceProvider, IQueryRuleCollection queryRuleCollection, IEnumerable <IUpdateRule> rules, IMapper mapper, IUnitOfWork unitOfWork) : base(descriptors, serviceProvider, queryRuleCollection) { if (rules == null) { throw new ArgumentNullException(nameof(rules)); } if (mapper == null) { throw new ArgumentNullException(nameof(mapper)); } var repoType = Descriptor.Bag.IsQueryType ? typeof(NotSupportedQueryRepositoryWrapper <,>) : typeof(RepositoryWrapper <,>); _repo = (IDynamicRepository <T>)Activator.CreateInstance( repoType.MakeGenericType(Descriptor.SourceType, typeof(T)), Context, Descriptor, serviceProvider, queryRuleCollection, EntityMap, rules, mapper); unitOfWork?.Use(_repo); }
public ExistsHandler(IDynamicRepository <T> repo) { _repo = repo; }
public CreateInvoiceCommand(IDynamicRepository repository) : base(repository) { }
public DeleteHandler(IDynamicRepository <T> repo) { _repo = repo; }
public static bool SendDocumentToSign(ObjectId tenantId, IDynamicRepository dynamicRepository, string fromEmail, string toEmail, string filePath) { var configuration = Utilities.Instance.GetConfiguration(); var subscriptionType = SubscriptionTypes.SignNow.ToString(); // Retrieve subscription by type...and user in the current tenant var subscription = dynamicRepository.GetAll <Subscription>(SchemaNames.Subscription.ToString(), tenantId).Select(r => (Subscription) new Subscription().Initialize <Subscription>(r.Values())) .FirstOrDefault(x => x.IsActive && x.Type.Name == subscriptionType); // Update subscription var accessToken = subscription.Token; var refreshToken = subscription.Secret; ISignNowService signNowService = new SignNowClient(tenantId, configuration.SignNowApiBaseUrl, accessToken); #region Retrieve user and extract email var userResponse = signNowService.RetrieveUser(); if (userResponse == null) { return(false); } var email = string.Empty; var userJson = JObject.Parse(userResponse); var emails = userJson.SelectTokens("emails").FirstOrDefault(); if (emails == null) { email = fromEmail; } else { email = (string)emails.FirstOrDefault(); } #endregion #region Document Signature Information dynamic documentSignatureInfo = new { fields = new[] { new { x = 370, y = 708, width = 208, height = 75, page_number = 0, role = "Customer", required = true, type = "signature" } } }; #endregion #region Invite Information dynamic inviteInfo = new { to = new[] { new { email = toEmail, role_id = "", role = "Customer", order = 1, } }, from = email, subject = configuration.SignNowInviteSubject, message = configuration.SignNowInviteMessage }; #endregion return(signNowService.SendRoleBasedInvite(filePath, documentSignatureInfo, inviteInfo)); }
private static void UpdateRoot(IDynamicRepository repository, AggregateRootDefine define, DynamicRoot root) { repository.Update(define, root); //保存修改后的数据 AddMemberRoots(repository, define, root); //有可能修改后的数据包含新的根成员需要增加 }
public static ObjectId DeepCreate(DynamicRecord parentRecord, DynamicRecord record, SchemaView view, ObjectId tenantId, ObjectId loggedUser, IDynamicRepository dynamicRepository, Dictionary <string, SchemaView> views, bool allowUpdate = false) { var complexRecords = record.Values().Where(v => view.Schema.Attributes.ContainsKey(v.Key) && (view.Schema.Attributes[v.Key].IsComplex || view.Schema.Attributes[v.Key].IsSubCatalog)); complexRecords.ToList().ForEach(r => { var subcatalogView = views.FirstOrDefault(x => x.Key == string.Format("{0}.{1}.{2}", view.Schema.Attributes[r.Key].DataType, ViewCategory.Create.ToString(), "Default")).Value; //this should go to cache all of the time, it would be expensive not to. // When manually creating an invoice, we need to check if Count > 0, otherwise FindExisting throws an exception if (r.Value is Dictionary <string, object> && ((Dictionary <string, object>)r.Value).Count > 0) { var subRecord = new DynamicRecord().Initialize <DynamicRecord>((Dictionary <string, object>)r.Value, null, ViewCategory.Create); bool isValidInput = true; subRecord._id = FindExisting(subRecord, subcatalogView, tenantId, loggedUser, dynamicRepository, out isValidInput); if (subcatalogView.Schema.AllowQuickCreate && subRecord._id == ObjectId.Empty && isValidInput) { ((Dictionary <string, object>)r.Value)["_id"] = DeepCreate(parentRecord ?? record, subRecord, subcatalogView, tenantId, loggedUser, dynamicRepository, views); } else if (subRecord._id != ObjectId.Empty) { ((Dictionary <string, object>)r.Value)["_id"] = subRecord._id; } } else if (r.Value is List <Dictionary <string, object> > && ((List <Dictionary <string, object> >)r.Value).Count > 0) { ((List <Dictionary <string, object> >)r.Value).ForEach(v => { var newId = DeepCreate(parentRecord ?? record, new DynamicRecord().Initialize <DynamicRecord>(v, subcatalogView, ViewCategory.Create), subcatalogView, tenantId, loggedUser, dynamicRepository, views, true); v["_id"] = newId; }); } }); if (record._id != ObjectId.Empty && allowUpdate) { record.ParentRecord = parentRecord; dynamicRepository.Edit(record, view.Schema.Name, tenantId, loggedUser, views); return(record._id); } else { var isValidInput = false; record._id = FindExisting(record, view, tenantId, loggedUser, dynamicRepository, out isValidInput); if (record._id == ObjectId.Empty) { record.ParentRecord = parentRecord; var returnId = dynamicRepository.AddReturnId(record, view.Schema.Name, tenantId, loggedUser, views); return(new ObjectId(returnId)); } else if (allowUpdate) { record.ParentRecord = parentRecord; dynamicRepository.Edit(record, view.Schema.Name, tenantId, loggedUser, views); return(record._id); } else { return(ObjectId.Empty); } } }
public static ObjectId DeepCreate(DynamicRecord record, SchemaView view, ObjectId tenantId, ObjectId loggedUser, IDynamicRepository dynamicRepository, Dictionary <string, SchemaView> views, bool allowUpdate = false) { return(DeepCreate(null, record, view, tenantId, loggedUser, dynamicRepository, views, allowUpdate)); }
public DynamicFilterManager(IDynamicFilterFactory dynamicFilterFactory, IDynamicRepository dynamicRepository, IDynamicMvcManager dynamicMvcManager) { _dynamicFilterFactory = dynamicFilterFactory; _dynamicRepository = dynamicRepository; _dynamicMvcManager = dynamicMvcManager; }
public CountHandler(IDynamicRepository <T> repo) { _repo = repo; }
public DynamicPropertyViewModelBuilder(IDynamicMvcManager dynamicMvcManager, IDynamicRepository dynamicRepository) { _dynamicMvcManager = dynamicMvcManager; _dynamicRepository = dynamicRepository; }
public PagingManager(IDynamicRepository dynamicRepository, IRequestManager requestManager) { _dynamicRepository = dynamicRepository; _requestManager = requestManager; }
public static ObjectId FindExisting(DynamicRecord record, SchemaView view, ObjectId tenantId, ObjectId loggedUser, IDynamicRepository dynamicRepository, out bool isValidInput) { isValidInput = true; //check if the current record exists... only check for quick create ones if ((record._id == null || record._id == ObjectId.Empty) && view.Schema.UniqueIndex != null) { var filter = view.Schema.UniqueIndex.ToDictionary(v => v, v => record[v]?.ToString()); // If all filters are empty that's because we're receiving an object without a unique index, // which can't be compared if (filter.All(x => string.IsNullOrEmpty(x.Value))) { // We received something without a valid uniqueIndex isValidInput = false; } else { var existingRecords = dynamicRepository.GetAll <DynamicRecord>(view.Schema.Name, tenantId, null); var existingRecord = existingRecords.Where(e => e.Contains(filter)).ToList(); if (existingRecord != null && existingRecord.Count() > 0) { return(existingRecord.First()._id); } } } return(ObjectId.Empty); }
/// <summary> /// 新增对象到本地仓储 /// </summary> /// <param name="repository"></param> /// <param name="define"></param> /// <param name="root"></param> private static void AddRoot(IDynamicRepository repository, AggregateRootDefine define, DynamicRoot root) { repository.Add(define, root); AddMemberRoots(repository, define, root); }