예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        public void CreateMapping(MappingModel model)
        {
            var template = TemplateService.GetSingleTemplate(model.GcTemplate.Id);
            var project  = ProjectsService.GetSingleProject(template.Data.ProjectId.ToString());

            var templateMapping = new TemplateMapping
            {
                MappingId         = model.MappingId,
                MappingTitle      = model.MappingTitle,
                DefaultLocationId = model.DefaultLocationId,
                LastUpdatedDate   = template.Data.Updated.ToString(),
                GcProjectId       = project.Data.Id.ToString(),
                GcProjectName     = project.Data.Name,
                CmsTemplate       = new CmsTemplate
                {
                    TemplateId = model.CmsTemplate.Id
                },
                GcTemplate = new GcTemplate
                {
                    GcTemplateId   = template.Data.Id.ToString(),
                    GcTemplateName = template.Data.Name
                },
            };

            var fieldMappings = ConvertToFieldMappings(model.FieldMappings);

            templateMapping.FieldMappings = fieldMappings;
            MappingRepository.CreateMapping(templateMapping);
        }
예제 #2
0
        public IHttpActionResult Automate([FromBody] AutomatedEntityMappingViewModel entityMapping)
        {
            try
            {
                if (entityMapping == null)
                {
                    return(BadRequest("EntityMapping cannot be null"));
                }
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                //var learningSession = new LearningSession(new UntrainedData
                //{
                //    Sources = _entityRepo.GetAll().Where(t => t.SystemId == entityMapping.SourceSystemId).Select(t => t.Name).ToList(),
                //    Destinations = _entityRepo.GetAll().Where(t => t.SystemId == entityMapping.DestinationSystemId).Select(t => t.Name).ToList()
                //});
                //var result = learningSession.StartLearning();


                var automatedMapping = new AutomatedMapping
                {
                    DestinationId  = 177,
                    SourceId       = 176,
                    LearningResult = new LearningResult(new List <LearntMapping>
                    {
                        new LearntMapping
                        {
                            Mapping = new Mapping
                            {
                                Source      = "qmob_commodity",
                                Destination = "qcommodity"
                            }
                        }
                    })
                };

                //new AutomatedMapping
                //{
                //    LearningResult = result,
                //    SourceId = entityMapping.SourceSystemId,
                //    DestinationId = entityMapping.DestinationSystemId
                //}

                var newMappings = _mappingRepository.CreateMapping(automatedMapping);
                return(Ok(Mapper.Map <IEnumerable <EntityMappingViewModel> >(newMappings)));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }