示例#1
0
        public List <MailStructure> Generate()
        {
            var mailList = new List <MailStructure>();

            for (int i = 0; i < ApplicationConstant.numberOfMails; i++)
            {
                var key             = (ApplicationConstant.startKey + i).ToString();
                var attachment_text = String.Empty;

                //if (HasAttachment(key))
                //{
                //    attachment_text = extractor.Extract(key);
                //}

                attachment_text = GenerateAttachmentPDF(key);

                var topic = GenerateTopic();
                var body  = GenerateBody();
                var date  = GenerateDate();

                mailList.Add(new MailStructure()
                {
                    _key  = key,
                    _id   = ApplicationConstant.prefixMail + key,
                    _from = ApplicationConstant.prefixPerson + GenerateFromAndTo().from,
                    _to   = ApplicationConstant.prefixPerson + GenerateFromAndTo().to,
                    type  = "mail",
                    topic = topic,
                    body  = body,
                    text_from_attachment = attachment_text,
                    date = DateToString(date)
                });

                var client = new RESTfulClient();
                client.UploadToElasticSearch(body, topic, attachment_text, DateToShortString(date), key);
            }

            return(mailList);
        }
示例#2
0
 public MailUploader()
 {
     restClient = new RESTfulClient();
 }