Пример #1
0
        private void ImportDataRaven()
        {
            Console.Clear();
            Console.WriteLine("Importando. Aguarde...");

            List <TwitterModel> listaDados = twitterDao.GetList();

            if (listaDados != null && listaDados.Count > 0)
            {
                foreach (TwitterModel tm in listaDados)
                {
                    twitterDao.Delete(tm);
                }
            }

            Criptografia cript = new Criptografia();

            cript.Key = "Teste";

            using (FileStream readStream = new FileStream(strNameFile, FileMode.Open))
            {
                while (readStream.Position < readStream.Length)
                {
                    if (readStream.Position > 0)
                    {
                        readStream.Position += 1;
                    }
                    long posicao = readStream.Position;

                    BinarySearchAlgorithm bsa = new BinarySearchAlgorithm();
                    StrFile oReturn           = bsa.GetFileValue <StrFile>(readStream);

                    TwitterModel twModel = new TwitterModel();
                    twModel.Id       = oReturn.Id.ToString();
                    twModel.Usuario  = oReturn.Usuario;
                    twModel.Mensagem = oReturn.Mensagem;
                    twModel.Data     = oReturn.Data.Trim() + "9";
                    twModel.Pais     = oReturn.Pais;

                    List <string> listaHash     = new List <string>();
                    string[]      hashTagsArray = oReturn.HashTags.Split("#");
                    if (hashTagsArray != null && hashTagsArray.Length > 0)
                    {
                        for (int k = 0; k < hashTagsArray.Length; k++)
                        {
                            if (k != 0)
                            {
                                string hashStr = "#" + hashTagsArray[k].Trim();
                                listaHash.Add(cript.Encrypt(hashStr));
                            }
                        }
                    }
                    twModel.HashTags = listaHash;
                    twitterDao.Store(twModel);
                }
            }

            Console.WriteLine("Pressione uma tecla para continuar.");
            Console.ReadKey();
        }
Пример #2
0
 public void Delete(TwitterModel model)
 {
     using (var session = documentStore.OpenSession())
     {
         session.Delete(model.Id);
         session.SaveChanges();
     }
 }
Пример #3
0
        private void GetDataRavenById()
        {
            Console.Clear();

            Console.WriteLine("Informe o ID");
            string idBusca = Console.ReadLine();

            Criptografia cript = new Criptografia();

            cript.Key = "Teste";

            DateTime begin = DateTime.UtcNow;

            TwitterModel tm = twitterDao.GetData(idBusca);

            if (tm != null)
            {
                StringBuilder sb = new StringBuilder();
                foreach (string s in tm.HashTags)
                {
                    sb.Append(cript.Decrypt(s));
                }

                Console.WriteLine(string.Format("ID: {0}|Usuário: {1}|Data: {2}|HashTags: {3}", tm.Id, tm.Usuario, tm.Data.Trim(), sb.ToString()));

                double total = (DateTime.UtcNow - begin).TotalMilliseconds;

                DesempenhoModel dm = new DesempenhoModel();
                dm.NomeTeste     = "Tempo índice(BD)";
                dm.TempoExecucao = total;
                dm.Data          = DateTime.Now;
                desempenhoDao.Store(dm);
            }
            else
            {
                Console.WriteLine("ID não encontrado");
            }

            Console.WriteLine("Pressione uma tecla para continuar.");
            Console.ReadKey();
        }