Exemple #1
0
        public override async Task Load(Stream content, LoadContext ldContext)
        {
            logger.Info("elasticsearch loaded:" + ldContext.LoadEvent.JobId);
            StreamReader reader = new StreamReader(content);
            List <TransformFieldWithValue> values =
                JsonConvert.DeserializeObject <List <TransformFieldWithValue> >(
                    await reader.ReadToEndAsync());

            var instanceWithType = elasticSearchType.GetInstanceWithName(ldContext.Parameter.ToString());

            instanceWithType.Model.Deserialze(values.Select(x => new KeyValuePair <string, List <string> >(x.Name, x.Value)));
            if (!instanceWithType.Model.IsEmpty)
            {
                var documentExist = elasticSearch.GetType().GetMethod(nameof(elasticSearch.DocumentExist))
                                    .MakeGenericMethod(instanceWithType.ModelType)
                                    .Invoke(elasticSearch, new object[] { instanceWithType.Model.ExistSearchKey, instanceWithType.Model.ExistSearchValue }) as Task <bool>;
                if (!await documentExist)
                {
                    var insertDocumentTask = elasticSearch.GetType().GetMethod(nameof(elasticSearch.InsertDocument))
                                             .MakeGenericMethod(instanceWithType.ModelType)
                                             .Invoke(elasticSearch, new object[] { instanceWithType.Model }) as Task;
                    await insertDocumentTask;
                }
            }
        }
Exemple #2
0
        public override async Task Load(Stream content, LoadContext ldContext)
        {
            using (MemoryStream memoryStream = new MemoryStream())
            {
                await content.CopyToAsync(memoryStream);

                var    hashHex  = memoryStream.ToArray().ToMD5Hash().ToHex();
                string fileName = ldContext.Parameter.ToString();
                fileName = ReplateHashPlaceHolder(hashHex, fileName);
                fileName = ReplaceDateTime(fileName);
                memoryStream.Seek(0, SeekOrigin.Begin);
                await storage.WriteStream(memoryStream, fileName);
            }
        }
 public override Task Load(Stream content, LoadContext ldContext)
 {
     throw new NotImplementedException();
 }
Exemple #4
0
 public abstract Task Load(Stream content, LoadContext paramter);