示例#1
0
        public IActionResult EditJob(Guid jobId)
        {
            var jobVm = MappingUtils.MapToNew <Job, JobVm>(_settingsBlProvider.GetSingleJob(jobId));


            return(PartialView("_EditJob", jobVm));
        }
示例#2
0
        /// <summary>
        /// Maps a directory to the project file
        /// </summary>
        /// <param name="prj">The active project</param>
        /// <param name="localPath">The local path</param>
        /// <param name="remotePath">The remote path</param>
        private void MapDirectoryAbsolutePath(Project prj, string localPath, string remotePath)
        {
            String     rPth = prj.Connection.Data.RootDir + remotePath;
            MappedPath path = MappingUtils.GetMappedPath(prj, localPath, remotePath);

            this.MapDirectory(prj, path);
        }
示例#3
0
        private void CreateIndex()
        {
            var doc = new MappingChildParentRoutingTestsLevel1
            {
                MappingChildParentRoutingTestsLevel1Id = 1,
                Level2 = new MappingChildParentRoutingTestsLevel2()
                {
                    MappingChildParentRoutingTestsLevel2Id = 2,
                    Level3 = new MappingChildParentRoutingTestsLevel3()
                    {
                        MappingChildParentRoutingTestsLevel3Id = 3
                    }
                }
            };

            _elasticsearchMappingResolver.AddElasticSearchMappingForEntityType(typeof(MappingChildParentRoutingTestsLevel1),
                                                                               MappingUtils.GetElasticsearchMapping <MappingChildParentRoutingTestsLevel1>(new IndexTypeDescription("masterindex", "level1")));
            _elasticsearchMappingResolver.AddElasticSearchMappingForEntityType(typeof(MappingChildParentRoutingTestsLevel2),
                                                                               MappingUtils.GetElasticsearchMapping <MappingChildParentRoutingTestsLevel2>(new IndexTypeDescription("masterindex", "level2")));
            _elasticsearchMappingResolver.AddElasticSearchMappingForEntityType(typeof(MappingChildParentRoutingTestsLevel3),
                                                                               MappingUtils.GetElasticsearchMapping <MappingChildParentRoutingTestsLevel3>(new IndexTypeDescription("masterindex", "level3")));

            using (var context = new ElasticsearchContext(ConnectionString,
                                                          new ElasticsearchSerializerConfiguration(_elasticsearchMappingResolver, true, true, true)))
            {
                context.TraceProvider = new ConsoleTraceProvider();
                context.AddUpdateDocument(doc, doc.MappingChildParentRoutingTestsLevel1Id);

                var ret = context.SaveChangesAndInitMappings();
                // Save to Elasticsearch
                Assert.AreEqual(ret.Status, HttpStatusCode.OK);
            }
        }
示例#4
0
        private void CreateDataDefinition()
        {
            var type = GetType();

            int definitionId;

            lock (DataDefinitions)
            {
                if (DataDefinitions.Contains(type))
                {
                    // We've already declared this data definition so return
                    return;
                }

                definitionId = DataDefinitions.Count;
                DataDefinitions.Add(type);
            }

            var properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public)
                             .Where(p => p.GetCustomAttributes(typeof(SimQueryVariableAttribute)).Any())
                             .ToList();

            foreach (var property in properties)
            {
                var attribute      = property.GetCustomAttribute <SimQueryVariableAttribute>();
                var datumName      = MappingUtils.ConvertSimVariableToSimulationString(attribute.Variable);
                var uom            = MappingUtils.ConvertUnitOfMeasurementToSimulationString(attribute.UnitOfMeasurement);
                var simConnectType = MappingUtils.GetSimConnectDataTypeMapping(property.PropertyType);
                _simConnect.AddToDataDefinition((DummyEnum)definitionId, datumName, uom, simConnectType, 0f, 0);
            }
        }
示例#5
0
        protected AliasBaseParameters(string alias, string index)
        {
            MappingUtils.GuardAgainstBadIndexName(alias);
            MappingUtils.GuardAgainstBadIndexName(index);

            _alias = alias;
            _index = index;
        }
示例#6
0
        public ActionResult SaveMapping(ComplexMappingModel model)
        {
            MappingManager mappingManager = new MappingManager();

            //save link element if not exits
            //source
            try
            {
                #region save or update RootMapping

                //create source Parents if not exist
                LinkElement sourceParent = MappingHelper.CreateIfNotExistLinkElement(model.Source.Parent, mappingManager);

                //create source Parents if not exist
                LinkElement targetParent = MappingHelper.CreateIfNotExistLinkElement(model.Target.Parent, mappingManager);

                //create root mapping if not exist
                Mapping rootMapping = MappingHelper.CreateIfNotExistMapping(sourceParent, targetParent, 0, null, null, mappingManager);

                #endregion

                #region save or update complex mapping
                LinkElement source;
                LinkElement target;

                //create source
                source = MappingHelper.CreateIfNotExistLinkElement(model.Source, sourceParent.Id, mappingManager);

                model.Source.Id = source.Id;
                model.Source    = MappingHelper.LoadChildren(model.Source);

                //create target
                target = MappingHelper.CreateIfNotExistLinkElement(model.Target, targetParent.Id, mappingManager);

                model.Target.Id = target.Id;
                model.Target    = MappingHelper.LoadChildren(model.Target);

                //save mapping
                Mapping mapping = MappingHelper.CreateIfNotExistMapping(source, target, 1, null, rootMapping, mappingManager);
                model.Id       = mapping.Id;
                model.ParentId = mapping.Parent.Id;
                #endregion

                #region create or update simple mapping

                MappingHelper.UpdateSimpleMappings(source.Id, target.Id, model.SimpleMappings, mapping, mappingManager);

                #endregion

                //load all mappings
                return(PartialView("Mapping", model));
            }
            finally
            {
                mappingManager.Dispose();
                MappingUtils.Clear();
            }
        }
示例#7
0
        static void Main(string[] args)
        {
            JsonConvert jsonFile = new JsonConvert();

            List <ExperimentData>            experimentDataList = DatabaseUtils.GetExperimentFromDatabase();
            List <ExperimentDataWithMapping> experimentDataListWithTeamGroup = MappingUtils.MappingTeamName(experimentDataList);

            jsonFile.ConvertToJson(experimentDataListWithTeamGroup);
        }
示例#8
0
        private void Send(string exchangeName, string routingKey, IMessage requestMessage, CorrelationData correlationData)
        {
            var converter = Template.MessageConverter;

            var message = MappingUtils.MapMessage(requestMessage, converter, HeaderMapper, DefaultDeliveryMode, HeadersMappedLast);

            AddDelayProperty(message);
            Template.Send(exchangeName, routingKey, message, correlationData);
        }
示例#9
0
        public IActionResult Index()
        {
            var model = (CompletionIndexModel)IndexModel;

            model.Completions = _completionBlProvider.GetCollection()
                                .Select(t => MappingUtils.MapToNew <Completion, CompletionVm>(t)).ToList();


            return(View(model));
        }
示例#10
0
        private static bool hasSimpleMapping(long id, LinkElementType type)
        {
            if (MappingUtils.ExistSimpleMappingWithParty(id, type) ||
                MappingUtils.ExistSimpleMappingWithPartyCustomType(id, type))
            {
                return(true);
            }

            return(false);
        }
示例#11
0
        public IActionResult EditJob(JobVm model)
        {
            if (ModelState.IsValid)
            {
                var entityModel = MappingUtils.MapToNew <JobVm, Job>(model);
                _settingsBlProvider.UpdateJob(entityModel);
            }

            return(RedirectToAction("JobsManagement", "Settings"));
        }
示例#12
0
        public virtual async Task <TItem> AddOrUpdateAsync(TItem item)
        {
            var existingItem = await Repository.GetAsync(item.Id);

            if (existingItem != null)
            {
                // ReSharper disable once AssignNullToNotNullAttribute
                return(UpdateExisting(MappingUtils.Map <TItem>(existingItem, item)));
            }

            return(Add(item));
        }
示例#13
0
        private JobLog GetLogException(string fileName, Exception exception)
        {
            var jobLog = MappingUtils.MapToNew <Exception, JobLog>(exception);

            jobLog.Message = exception.Message.ToString();
            jobLog.Name    = fileName;
            if (exception.InnerException != null)
            {
                jobLog.InnerLog = GetLogException(fileName, exception.InnerException);
            }

            return(jobLog);
        }
示例#14
0
        /// <summary>
        ///     Reindex constructor. The class reuires a index and a type for the old index and also
        ///     the new index. The old index can then be converteds or reindexed to the new index.
        /// </summary>
        /// <param name="oldIndexTypeDescription">
        ///     index and index type parameters for the old index
        /// </param>
        /// <param name="newIndexTypeDescription">
        ///     index and index type parameters for the new index
        /// </param>
        /// <param name="connectionString">        Elastic connection string </param>
        public ElasticReindex(IndexTypeDescription oldIndexTypeDescription,
                              IndexTypeDescription newIndexTypeDescription, string connectionString)
        {
            _oldIndexTypeDescription = oldIndexTypeDescription;
            _newIndexTypeDescription = newIndexTypeDescription;
            IElasticMappingResolver elasticMappingResolver = new ElasticMappingResolver();

            elasticMappingResolver.AddElasticSearchMappingForEntityType(typeof(TNew),
                                                                        MappingUtils.GetElasticMapping <TNew>(newIndexTypeDescription));
            elasticMappingResolver.AddElasticSearchMappingForEntityType(typeof(TOld),
                                                                        MappingUtils.GetElasticMapping <TOld>(oldIndexTypeDescription));
            _context = new ElasticContext(connectionString, elasticMappingResolver);
        }
示例#15
0
        public async Task <ResultDetails <string> > CreateTypeMappingForIndexAsync <T>(MappingDefinition mappingDefinition)
        {
            if (mappingDefinition == null)
            {
                throw new ElasticException(
                          "CreateTypeMappingForIndexAsync: A mapping definition with the parent index is required");
            }
            _traceProvider.Trace(TraceEventType.Verbose, "{0}: CreateTypeMappingForIndex Elastic started",
                                 "ElasticContextIndexMapping");
            var resultDetails = new ResultDetails <string> {
                Status = HttpStatusCode.InternalServerError
            };

            try
            {
                var indexMappings = new IndexMappings(_traceProvider, _elasticSerializerConfiguration);

                var item = Activator.CreateInstance <T>();

                var entityContextInfo = new EntityContextInfo
                {
                    RoutingDefinition = mappingDefinition.RoutingDefinition,
                    Document          = item,
                    EntityType        = typeof(T),
                    Id = "0"
                };

                if (string.IsNullOrEmpty(mappingDefinition.Index))
                {
                    var index = _elasticSerializerConfiguration.ElasticMappingResolver
                                .GetElasticSearchMapping(entityContextInfo.EntityType)
                                .GetIndexForType(entityContextInfo.EntityType);
                    MappingUtils.GuardAgainstBadIndexName(index);
                    mappingDefinition.Index = index;
                }

                indexMappings.CreatePropertyMappingForTopDocument(entityContextInfo, mappingDefinition);
                await indexMappings.Execute(_client, _connectionString, _traceProvider, _cancellationTokenSource);

                return(resultDetails);
            }
            catch (OperationCanceledException oex)
            {
                _traceProvider.Trace(TraceEventType.Warning, oex,
                                     "{1}: CreateTypeMappingForIndexAsync Request OperationCanceledException: {0}", oex.Message,
                                     "ElasticContextIndexMapping");
                resultDetails.Description = "OperationCanceledException";
                return(resultDetails);
            }
        }
        //====== IRequestHandler

        public async Task<AppUser?> Handle( TryGetAppUserQuery request, CancellationToken cancellationToken )
        {
            AppUserEntity? entity = await context.Entities
                .AppUsers
                .AsNoTracking()
                .Include( x => x.UserRoles )
                .FirstOrDefaultAsync( x => x.UserName == request.UserName.Value );

            if (entity is null) return null;

            bool validPass = hasher.VerifyHash( entity.PasswordHash, request.Password );

            return validPass ? MappingUtils.ToAppUser( entity ) : null;
        }
示例#17
0
        public async Task <ResultDetails <string> > CreateIndexWithMappingAsync <T>(IndexDefinition indexDefinition)
        {
            if (indexDefinition == null)
            {
                indexDefinition = new IndexDefinition();
            }
            _traceProvider.Trace(TraceEventType.Verbose, "{0}: CreateIndexWithMappingAsync Elastic started",
                                 "ElasticContextIndexMapping");
            var resultDetails = new ResultDetails <string> {
                Status = HttpStatusCode.InternalServerError
            };

            try
            {
                var item = Activator.CreateInstance <T>();
                var entityContextInfo = new EntityContextInfo
                {
                    RoutingDefinition = indexDefinition.Mapping.RoutingDefinition,
                    Document          = item,
                    EntityType        = typeof(T),
                    Id = "0"
                };

                var index =
                    _elasticSerializerConfiguration.ElasticMappingResolver.GetElasticSearchMapping(
                        entityContextInfo.EntityType)
                    .GetIndexForType(entityContextInfo.EntityType);
                MappingUtils.GuardAgainstBadIndexName(index);

                var indexMappings = new IndexMappings(_traceProvider, _elasticSerializerConfiguration);
                indexMappings.CreateIndexSettingsAndMappingsForDocument(
                    index,
                    indexDefinition.IndexSettings,
                    indexDefinition.IndexAliases,
                    indexDefinition.IndexWarmers, entityContextInfo, indexDefinition.Mapping);
                indexDefinition.Mapping.Index = index;
                //indexMappings.CreatePropertyMappingForTopDocument(entityContextInfo, indexDefinition.Mapping);
                await indexMappings.Execute(_client, _connectionString, _traceProvider, _cancellationTokenSource);

                return(resultDetails);
            }
            catch (OperationCanceledException oex)
            {
                _traceProvider.Trace(TraceEventType.Warning, oex,
                                     "{1}: CreateIndexWithMappingAsync Request OperationCanceledException: {0}", oex.Message,
                                     "ElasticContextIndexMapping");
                resultDetails.Description = "OperationCanceledException";
                return(resultDetails);
            }
        }
示例#18
0
        public async Task <ResultDetails <string> > CreateIndexAsync(string index, IndexSettings indexSettings,
                                                                     IndexAliases indexAliases, IndexWarmers indexWarmers)
        {
            if (string.IsNullOrEmpty(index))
            {
                throw new ElasticException("CreateIndexAsync: index is required");
            }
            if (indexSettings == null)
            {
                indexSettings = new IndexSettings {
                    NumberOfShards = 5, NumberOfReplicas = 1
                }
            }
            ;
            if (indexAliases == null)
            {
                indexAliases = new IndexAliases();
            }

            if (indexWarmers == null)
            {
                indexWarmers = new IndexWarmers();
            }

            _traceProvider.Trace(TraceEventType.Verbose, "{0}: CreateIndexAsync Elastic started",
                                 "ElasticContextIndexMapping");
            var resultDetails = new ResultDetails <string> {
                Status = HttpStatusCode.InternalServerError
            };

            try
            {
                MappingUtils.GuardAgainstBadIndexName(index);

                var indexMappings = new IndexMappings(_traceProvider, _elasticSerializerConfiguration);
                indexMappings.CreateIndexSettingsForDocument(index, indexSettings, indexAliases, indexWarmers);
                await indexMappings.Execute(_client, _connectionString, _traceProvider, _cancellationTokenSource);

                return(resultDetails);
            }
            catch (OperationCanceledException oex)
            {
                _traceProvider.Trace(TraceEventType.Warning, oex,
                                     "{1}: CreateIndexAsync Request OperationCanceledException: {0}", oex.Message,
                                     "ElasticContextIndexMapping");
                resultDetails.Description = "OperationCanceledException";
                return(resultDetails);
            }
        }
示例#19
0
        private PanageaMetadata getMetadata(XmlDocument metadata, long metadataStructureId)
        {
            List <string> tmp = new List <string>();

            PanageaMetadata pangaeaMetadata = new PanageaMetadata();

            //get title
            tmp = MappingUtils.GetValuesFromMetadata((int)Key.Title, LinkElementType.Key,
                                                     metadataStructureId, XmlUtility.ToXDocument(metadata));

            if (tmp != null)
            {
                pangaeaMetadata.Title = string.Join(",", tmp.ToArray());
            }

            //get Description
            tmp = MappingUtils.GetValuesFromMetadata((int)Key.Description, LinkElementType.Key,
                                                     metadataStructureId, XmlUtility.ToXDocument(metadata));

            if (tmp != null)
            {
                pangaeaMetadata.Abstract = string.Join(",", tmp.ToArray());
            }

            // get Authors
            tmp = MappingUtils.GetValuesFromMetadata((int)Key.Author, LinkElementType.Key,
                                                     metadataStructureId, XmlUtility.ToXDocument(metadata));

            if (tmp != null)
            {
                pangaeaMetadata.AuthorIDs = tmp;
            }

            // get Projects
            tmp = MappingUtils.GetValuesFromMetadata((int)Key.ProjectTitle, LinkElementType.Key,
                                                     metadataStructureId, XmlUtility.ToXDocument(metadata));

            if (tmp != null)
            {
                pangaeaMetadata.ProjectIDs = tmp;
            }

            // Defauls sets
            //ExportFileName
            pangaeaMetadata.ExportFilename = Regex.Replace(pangaeaMetadata.Title, "[^0-9a-zA-Z]+", "");

            return(pangaeaMetadata);
        }
示例#20
0
        private IMessageBuilder SendAndReceive(string exchangeName, string routingKey, IMessage requestMessage, CorrelationData correlationData)
        {
            var converter = Template.MessageConverter;

            var message = MappingUtils.MapMessage(requestMessage, converter, HeaderMapper, DefaultDeliveryMode, HeadersMappedLast);

            AddDelayProperty(message);

            var amqpReplyMessage = Template.SendAndReceive(exchangeName, routingKey, message, correlationData);

            if (amqpReplyMessage == null)
            {
                return(null);
            }

            return(BuildReply(converter, amqpReplyMessage));
        }
示例#21
0
        public ElasticSerializationResult Serialize(IEnumerable <EntityContextInfo> entities)
        {
            if (entities == null)
            {
                return(null);
            }

            _elasticSerializationResult = new ElasticSerializationResult();
            _elasticCrudJsonWriter      = new ElasticJsonWriter();

            foreach (var entity in entities)
            {
                var index = _elasticSerializerConfiguration.ElasticMappingResolver
                            .GetElasticSearchMapping(entity.EntityType).GetIndexForType(entity.EntityType);
                MappingUtils.GuardAgainstBadIndexName(index);

                if (_saveChangesAndInitMappingsForChildDocuments)
                {
                    _indexMappings.CreateIndexSettingsAndMappingsForDocument(
                        index,
                        new IndexSettings {
                        NumberOfShards = 5, NumberOfReplicas = 1
                    },
                        new IndexAliases(),
                        new IndexWarmers(),
                        entity, new MappingDefinition {
                        Index = index
                    });
                }

                if (entity.DeleteDocument)
                {
                    DeleteEntity(entity);
                }
                else
                {
                    AddUpdateEntity(entity);
                }
            }

            _elasticCrudJsonWriter.Dispose();
            _elasticSerializationResult.Content       = _elasticCrudJsonWriter.Stringbuilder.ToString();
            _elasticSerializationResult.IndexMappings = _indexMappings;
            return(_elasticSerializationResult);
        }
示例#22
0
        private static MappingTestsParent SetupIndexMappingTests(string index, out IElasticsearchMappingResolver elasticsearchMappingResolver)
        {
            var mappingTestsParent = new MappingTestsParent
            {
                Calls = 3,
                MappingTestsParentId = 2,
                MappingTestsItem     = new MappingTestsChild
                {
                    Description         = "Hello nested",
                    MappingTestsChildId = 5
                }
            };

            elasticsearchMappingResolver = new ElasticsearchMappingResolver();
            elasticsearchMappingResolver.AddElasticSearchMappingForEntityType(typeof(MappingTestsParent),
                                                                              MappingUtils.GetElasticsearchMapping(index));
            return(mappingTestsParent);
        }
示例#23
0
        /// <summary>
        /// Gets the mapped file paths from the given directory, using the project filtering
        /// The result is saved in the files List
        /// </summary>
        /// <param name="files">The list of mapped files</param>
        /// <param name="prj">The current project</param>
        /// <param name="dir">The mapped path directory</param>
        private void GetPaths(ref List <MappedPath> files, DirectoryInfo dirInfo, Project prj, MappedPath dirMap)
        {
            String servercopy = prj.Data.ServerCopy,
                   fileInServerCopy;

            foreach (var file in dirInfo.GetFiles())
            {
                //Files must exist in server copy and shouldn't be already added
                fileInServerCopy = file.FullName.Replace(MappingUtils.ValidatePath(prj.Data.ProjectCopy, true), MappingUtils.ValidatePath(prj.Data.ServerCopy, true)) + ".copy";
                if (File.Exists(fileInServerCopy) && files.Count(x => file.FullName == x.GetFullServerCopy()) == 0)
                {
                    files.Add(SftpUtils.GetMappedPath(file, dirMap.ProjectCopy, dirMap.RemotePath, dirMap.ServerCopy));
                }
            }
            foreach (var dir in dirInfo.GetDirectories())
            {
                GetPaths(ref files, dir, prj, dirMap);
            }
        }
        private static void Main(string[] args)
        {
            // Define the mapping for the type so that all use the same index as the parent
            ElasticsearchMappingResolver.AddElasticSearchMappingForEntityType(typeof(LeagueCup),
                                                                              MappingUtils.GetElasticsearchMapping("leagues"));
            ElasticsearchMappingResolver.AddElasticSearchMappingForEntityType(typeof(Team),
                                                                              MappingUtils.GetElasticsearchMapping("leagues"));
            ElasticsearchMappingResolver.AddElasticSearchMappingForEntityType(typeof(Player),
                                                                              MappingUtils.GetElasticsearchMapping("leagues"));
            ElasticsearchMappingResolver.AddElasticSearchMappingForEntityType(typeof(object),
                                                                              new GlobalLeaguesElasticsearchMapping());

            CreateIndexWithRouting();
            Console.ReadLine();

            var leagueAndRoutingId = CreateNewLeague();

            Console.ReadLine();

            var teamId = AddTeamToCup(leagueAndRoutingId);

            Console.ReadLine();

            AddPlayerToTeam(teamId, leagueAndRoutingId);
            Console.ReadLine();

            var player = GetPlayer(3, leagueAndRoutingId, teamId);

            Console.WriteLine("Found player: " + player.Name);
            Console.ReadLine();

            GetAllForRoute(leagueAndRoutingId);
            Console.ReadLine();

            var globalSearch = new GlobalSearch(ConnectionString);

            globalSearch.GetAllForRouteFilterForPlayersAndTeams(leagueAndRoutingId);
            Console.ReadLine();

            globalSearch.RunGlobalSearch();
            Console.ReadLine();
        }
示例#25
0
        public IActionResult Customer(long completionId = 0)
        {
            var user       = UserBlProvider.GetUser(User);
            var customerId = user.CustomerId;
            var model      = (CompletionIndexModel)IndexModel;

            var collection = _completionBlProvider.GetCustomerCollection(customerId, completionId);

            if (customerId != null)
            {
                model.Completions = collection
                                    .Select(t => MappingUtils.MapToNew <Completion, CompletionVm>(t)).ToList();
            }


            //if (collection.Count() == 1)
            //    _emailSendGridBlProvider.SendInvoiceCompleteNotification(collection.FirstOrDefault());

            return(View(model));
        }
示例#26
0
        public JsonResult DeleteMapping(long id)
        {
            try
            {
                using (MappingManager mappingManager = new MappingManager())
                {
                    MappingHelper.DeleteMapping(id, mappingManager);

                    //ToDo delete also all simple mappings that are belonging to the complex mapping
                    return(Json(true));
                }
            }
            catch (Exception ex)
            {
                return(Json(ex.Message));
            }
            finally
            {
                MappingUtils.Clear();
            }
        }
示例#27
0
        // GET: Test
        public ActionResult Index(long id = -1)
        {
            DatasetManager datasetManager = new DatasetManager();

            try
            {
                //get all
                var x = MappingUtils.GetAllMatchesInSystem(1, LinkElementType.MetadataNestedAttributeUsage);
                // get all where value = david
                x = MappingUtils.GetAllMatchesInSystem(1, LinkElementType.MetadataNestedAttributeUsage, "David");

                // get value from metadata over the system
                // partytpe person - attr firstname

                long            partyCustomtAttr = 1;
                LinkElementType type             = LinkElementType.PartyCustomType;

                long datasetId = id;

                DatasetVersion datasetVersion = datasetManager.GetDatasetLatestVersion(datasetId);

                List <string> tmp = MappingUtils.GetValuesFromMetadata(partyCustomtAttr, type,
                                                                       datasetVersion.Dataset.MetadataStructure.Id, XmlUtility.ToXDocument(datasetVersion.Metadata));

                tmp = MappingUtils.GetValuesFromMetadata(Convert.ToInt64(Key.Keyword), LinkElementType.Key,
                                                         datasetVersion.Dataset.MetadataStructure.Id, XmlUtility.ToXDocument(datasetVersion.Metadata));

                tmp = MappingUtils.GetValuesFromMetadata(Convert.ToInt64(Key.Author), LinkElementType.Key,
                                                         datasetVersion.Dataset.MetadataStructure.Id, XmlUtility.ToXDocument(datasetVersion.Metadata));

                tmp = MappingUtils.GetValuesFromMetadata(Convert.ToInt64(Key.Title), LinkElementType.Key,
                                                         datasetVersion.Dataset.MetadataStructure.Id, XmlUtility.ToXDocument(datasetVersion.Metadata));

                return(View("Index"));
            }
            finally
            {
                datasetManager.Dispose();
            }
        }
示例#28
0
        public void Setup()
        {
            var doc1 = new TestObjParentSep
            {
                Id           = 1,
                Info         = "yes this is great",
                ChildObjects = new List <TestObjChildSep>
                {
                    new TestObjChildSep
                    {
                        Id      = 1,
                        Details = "my child"
                    }
                }
            };

            var doc2 = new TestObjParentSep
            {
                Id           = 2,
                Info         = "yes this is great two child",
                ChildObjects = new List <TestObjChildSep>
                {
                    new TestObjChildSep
                    {
                        Id      = 1,
                        Details = "my child"
                    }
                }
            };

            var doc3 = new TestObjParentSep
            {
                Id           = 3,
                Info         = "yes this is great three",
                ChildObjects = new List <TestObjChildSep>
                {
                    new TestObjChildSep
                    {
                        Id      = 3,
                        Details = "my child three"
                    },
                    new TestObjChildSep
                    {
                        Id      = 4,
                        Details = "my child four"
                    }
                }
            };

            ElasticsearchMappingResolver.AddElasticSearchMappingForEntityType(typeof(TestObjChildSep),
                                                                              MappingUtils.GetElasticsearchMapping <TestObjChildSep>("testobjparentseps", "testobjchildsep"));

            using (var context = new ElasticsearchContext(ConnectionString, new ElasticsearchSerializerConfiguration(ElasticsearchMappingResolver, true, true)))
            {
                context.IndexCreate <TestObjParentSep>();
                Thread.Sleep(1200);
                context.AddUpdateDocument(doc1, doc1.Id);
                context.AddUpdateDocument(doc2, doc2.Id);
                context.AddUpdateDocument(doc3, doc3.Id);
                context.SaveChanges();
                Thread.Sleep(1200);
            }
        }
示例#29
0
        public IndexAlias(string alias)
        {
            MappingUtils.GuardAgainstBadIndexName(alias);

            _alias = alias;
        }
示例#30
0
        public XmlDocument SetSystemValuesToMetadata(long datasetid, long version, long metadataStructureId, XmlDocument metadata, params Key[] systemKeyList)
        {
            foreach (var t in systemKeyList)
            {
                //get all mappings to automatic system from the metadata structure
                var mappings = MappingUtils.GetMappingsWhereSource((int)t, LinkElementType.Key);

                if (mappings != null)
                {
                    if (mappings is List <Mapping> )
                    {
                        foreach (var mapping in mappings)
                        {
                            switch (t)
                            {
                            case Key.Id:
                            {
                                metadata = setValue(mapping.Target.XPath, datasetid.ToString(), metadata); break;
                            }

                            case Key.Version:
                            {
                                metadata = setValue(mapping.Target.XPath, version.ToString(), metadata); break;
                            }

                            case Key.DateOfVersion:
                            {
                                metadata = setValue(mapping.Target.XPath, DateTime.Now.ToString(), metadata); break;
                            }

                            case Key.MetadataCreationDate:
                            {
                                metadata = setValue(mapping.Target.XPath, DateTime.Now.ToString(), metadata); break;
                            }

                            case Key.MetadataLastModfied:
                            {
                                metadata = setValue(mapping.Target.XPath, DateTime.Now.ToString(), metadata); break;
                            }

                            case Key.DataCreationDate:
                            {
                                metadata = setValue(mapping.Target.XPath, DateTime.Now.ToString(), metadata); break;
                            }

                            case Key.DataLastModified:
                            {
                                metadata = setValue(mapping.Target.XPath, DateTime.Now.ToString(), metadata); break;
                            }
                            }
                        }
                    }
                }
            }

            //switch(key)
            //....


            // set values

            return(metadata);
        }