public void UpdateManyByProdutor(long idProdutor)
        {
            var ticks = DateTime.Now.Ticks;

            this.OptimizedUpdate(GISAUtils.GetIdsNiveisDocumentaisComProdutores(idProdutor));
            log.Debug("UpdateManyByProdutor: " + new TimeSpan(DateTime.Now.Ticks - ticks).ToString());
        }
Exemplo n.º 2
0
 public override void CreateIndex()
 {
     using (IndexWriter indexWriter = new IndexWriter(this.index, new NivelDocumentalSearcher.InstancePerFieldAnalyzerWrapper().instancePerFieldAnalyzerWrapper, IndexWriter.MaxFieldLength.UNLIMITED))
     {
         GISAUtils.getAllNivelDocumentalIds().ToList().ForEach(id => indexWriter.AddDocument(this.GetDocument(id)));
         indexWriter.Optimize();
         indexWriter.Dispose();
     }
 }
Exemplo n.º 3
0
 public override void CreateIndex()
 {
     using (IndexWriter indexWriter = new IndexWriter(this.index, new SynonymAnalyzer(new XmlSynonymEngine()), IndexWriter.MaxFieldLength.UNLIMITED))
     {
         GISAUtils.getAllNivelDocumentalInternetIds().ToList().ForEach(id => indexWriter.AddDocument(this.GetDocument(id)));
         indexWriter.Optimize();
         indexWriter.Dispose();
     }
 }
Exemplo n.º 4
0
        public void GetUser()
        {
            IList <long> ids = GISAUtils.GetTrusteeUsersIds("leitor");

            foreach (long id in ids)
            {
                Console.WriteLine(id);
            }
            Assert.AreEqual(1, ids.Count);
        }
Exemplo n.º 5
0
        public void GetAllUnidadesFisicas()
        {
            IList <long> ids = GISAUtils.getAllUnidadesFisicasIds();

            foreach (long id in ids)
            {
                UnidadeFisica uf = new UnidadeFisica(id);
                Assert.IsNotNull(uf);
            }
        }
Exemplo n.º 6
0
        public void MyUpdate(List <string> idsNivel)
        {
            //GISAUtils.GetIdsNiveisDocumentaisInternet(idsNivel);
            //this.Update(idsNivel);

            var ticks = DateTime.Now.Ticks;

            this.OptimizedUpdate(GISAUtils.GetIdsNiveisDocumentaisInternet(idsNivel));
            log.Debug("UpdateManyIdsNiveisDocumentaisInternet: " + new TimeSpan(DateTime.Now.Ticks - ticks).ToString());
        }
Exemplo n.º 7
0
        public void GetGroup()
        {
            IList <long> ids = GISAUtils.GetTrusteeUsersIds("t.Name = 'todos'");

            foreach (long id in ids)
            {
                Console.WriteLine(id);
            }
            Console.WriteLine("ids.count: {0}", ids.Count);
            Assert.IsTrue(ids.Count > 1);
        }
Exemplo n.º 8
0
        public new string Search(string searchText)
        {
            string   operador = GISAUtils.buildOperatorSearchString(ref searchText);
            DateTime?inicio   = null;
            DateTime?fim      = null;

            searchText = GISAUtils.buildDataInicialDataFinalSearchString(searchText, out inicio, out fim);
            List <string> nivelIds = GISAUtils.GetNivelIds(operador, inicio, fim);

            List <string> luceneResults;

            if (nivelIds == null) //no parameter was actually filled for GetNivelIds()
            {
                luceneResults = base.Search(searchText);
            }
            else
            {
                if (nivelIds.Count > 0)
                {
                    if (searchText.Length > 0)
                    {
                        string a = GISAUtils.buildList_Id_OR_Id(searchText, nivelIds);
                        luceneResults = base.Search(a);
                    }
                    else
                    {
                        luceneResults = nivelIds;
                    }
                }
                else
                {
                    luceneResults = new List <string>();
                }
            }

            Dictionary <string, string> test = new Dictionary <string, string>();

            List <string> ret = new List <string>();

            foreach (string id in luceneResults)
            {
                if (test.ContainsKey(id))
                {
                    continue;
                }

                test.Add(id, id);
                ret.Add(id);
            }

            return(string.Join(" ", ret.ToArray()));
        }
Exemplo n.º 9
0
        public void GetARandomUnidadeFisica()
        {
            IList <long> ids = GISAUtils.getAllUnidadesFisicasIds();

            if (ids.Count > 0)
            {
                Random random = new Random();
                int    pos    = random.Next(0, ids.Count - 1);

                UnidadeFisica uf = new UnidadeFisica(ids[pos]);
                Assert.IsNotNull(uf);
            }
        }
Exemplo n.º 10
0
        public void DateWellFormedString()
        {
            IList <long> ids = GISAUtils.getAllUnidadesFisicasIds();

            foreach (long id in ids)
            {
                UnidadeFisica uf = new UnidadeFisica(id);
                Console.WriteLine(uf.DataInicioProd);
                Console.WriteLine(uf.DataFimProd);
                Assert.AreEqual(8, uf.DataInicioProd.Length);
                Assert.AreEqual(8, uf.DataFimProd.Length);
            }
        }
Exemplo n.º 11
0
        public string Search(string searchText, long idTrustee)
        {
            var results = this.queryCacher.SearchInCache(idTrustee, searchText);

            if (results != null)
            {
                return(string.Join(" ", results.ToArray()));
            }

            string   operador = GISAUtils.buildOperatorSearchString(ref searchText);
            DateTime?inicio;
            DateTime?fim;

            searchText = GISAUtils.buildDataInicialDataFinalSearchString(searchText, out inicio, out fim);
            List <string> nivelIds = GISAUtils.GetNivelIds(operador, inicio, fim);

            List <string> luceneResults;

            if (nivelIds == null) //no parameter was actually filled for GetNivelIds()
            {
                luceneResults = base.Search(searchText);
            }
            else
            {
                if (nivelIds.Count > 0)
                {
                    if (searchText.Length > 0)
                    {
                        string a = GISAUtils.buildList_Id_OR_Id(searchText, nivelIds);
                        luceneResults = base.Search(a);
                    }
                    else
                    {
                        luceneResults = nivelIds;
                    }
                }
                else
                {
                    luceneResults = new List <string>();
                }
            }

            var c   = DateTime.Now.Ticks;
            var ret = Util.FilterByReadPermission(luceneResults, idTrustee);
            var b   = new TimeSpan(DateTime.Now.Ticks - c).ToString();

            queryCacher.Add(idTrustee, searchText, luceneResults);

            return(string.Join(" ", ret.ToArray()));
        }
Exemplo n.º 12
0
        public void GetFRDBases()
        {
            var ids = GISAUtils.GetNivelIds(string.Empty, null, new DateTime(2008, 10, 30));

            if (ids == null)
            {
                Assert.Fail("Parameters not specified?!");
            }

            foreach (string id in ids)
            {
                Console.WriteLine(id);
            }
            Console.WriteLine("ids.count: {0}", ids.Count);
            Assert.IsTrue(ids.Count > 1);
        }
Exemplo n.º 13
0
        public void GetARandomDocument()
        {
            IList <long> ids = GISAUtils.getAllNivelDocumentalIds();

            if (ids.Count > 0)
            {
                Random random = new Random();
                int    pos    = random.Next(0, ids.Count - 1);

                long            initMemory = GC.GetTotalMemory(true);
                NivelDocumental doc        = new NivelDocumental(ids[pos]);
                long            usedMemory = (GC.GetTotalMemory(true) - initMemory) / 1024;

                Console.WriteLine("One Document Memory: " + usedMemory.ToString() + "KB");
                Assert.IsNotNull(doc);
            }
        }
Exemplo n.º 14
0
        public static List <string> FilterByReadPermission(List <string> ids, long idTrustee)
        {
            ISession session = null;
            var      res     = new List <string>();

            try
            {
                session = GISAUtils.SessionFactory.OpenSession();

                using (SqlCommand command = new SqlCommand(string.Empty, (SqlConnection)session.Connection))
                {
                    GISAUtils.ImportIDs(ids.ToArray(), (SqlConnection)session.Connection);
                    command.CommandText = "CREATE TABLE #effective (IDNivel BIGINT PRIMARY KEY, IDUpper BIGINT, Ler TINYINT)";
                    command.ExecuteNonQuery();

                    command.CommandText = "INSERT INTO #effective SELECT ID, ID, null FROM #temp ORDER BY #temp.seq_nr";
                    command.ExecuteNonQuery();

                    command.CommandText = "sp_getEffectiveReadPermissions";
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add("@IDTrustee", SqlDbType.BigInt);
                    command.Parameters[0].Value = idTrustee;
                    command.ExecuteNonQuery();
                    command.Parameters.Clear();

                    command.CommandType = CommandType.Text;
                    command.CommandText = "SELECT IDNivel FROM #effective INNER JOIN #temp ON #temp.ID = #effective.IDNivel WHERE Ler = 1 ORDER BY #temp.seq_nr";
                    var reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        res.Add(reader.GetInt64(0).ToString());
                    }
                    reader.Close();
                }
            }
            catch (Exception) { throw; }
            finally
            {
                if (session != null)
                {
                    session.Close();
                }
            }
            return(res);
        }
        public new string Search(string searchText)
        {
            string   operador = GISAUtils.buildOperatorSearchString(ref searchText);
            DateTime?inicio;
            DateTime?fim;

            searchText = GISAUtils.buildDataInicialDataFinalSearchString(searchText, out inicio, out fim);
            List <string> nivelIds = GISAUtils.GetNivelIds(operador, inicio, fim);

            List <string> luceneResults;

            if (nivelIds == null) //no parameter was actually filled for GetNivelIds()
            {
                luceneResults = base.Search(searchText);
            }
            else
            {
                if (nivelIds.Count > 0)
                {
                    if (searchText.Length > 0)
                    {
                        string a = GISAUtils.buildList_Id_OR_Id(searchText, nivelIds);
                        luceneResults = base.Search(a);
                    }
                    else
                    {
                        luceneResults = nivelIds;
                    }
                }
                else
                {
                    luceneResults = new List <string>();
                }
            }

            return(string.Join(" ", luceneResults.ToArray()));
        }
Exemplo n.º 16
0
        public void GetAllNivelDocumental()
        {
            try
            {
                IList <long> ids = GISAUtils.getAllNivelDocumentalIds();

                long initMemory = GC.GetTotalMemory(true);
                foreach (long id in ids)
                {
                    NivelDocumental doc = new NivelDocumental(id);
                    Assert.IsNotNull(doc);
                }
                long usedMemory = (GC.GetTotalMemory(true) - initMemory) / 1024;

                GC.Collect();
                GC.WaitForPendingFinalizers();

                Console.WriteLine("All Documents Memory: " + usedMemory.ToString() + "KB");
            }
            catch (InsufficientMemoryException)
            {
                Console.WriteLine("It's too much for me...!");
            }
        }
Exemplo n.º 17
0
        public UnidadeFisica(long idNivel)
        {
            ISession session = null;

            try
            {
                session = GISAUtils.SessionFactory.OpenSession();
                var ufs = session.CreateSQLQuery(GISAUtils.getAllUnidadesFisicasQuery + " and n.ID = " + idNivel.ToString());
                ufs.SetTimeout(1000);

                foreach (var uf in ufs.List <object[]>())
                {
                    this.id                    = uf[0].ToString();
                    this.numero                = uf[1].ToString();
                    this.designacao            = uf[2].ToString();
                    this.codigoBarras          = uf[3].ToString();
                    this.guiaIncorporacao      = uf[4].ToString();
                    this.eliminado             = uf[5].ToString().Equals("1") ? "sim" : "nao";
                    this.cota                  = uf[6].ToString();
                    this.dataInicioProd        = GISAUtils.DataInicioProdFormatada(uf[7].ToString(), uf[8].ToString(), uf[9].ToString());
                    this.dataFimProd           = GISAUtils.DataInicioProdFormatada(uf[10].ToString(), uf[11].ToString(), uf[12].ToString());
                    this.conteudoInformacional = uf[13].ToString();
                    this.tipoUnidadeFisica     = uf[14].ToString();
                }
            }
            catch (Exception) { throw; }
            finally
            {
                if (session != null)
                {
                    session.Close();
                }
            }

            //ISession session = null;
            //try
            //{
            //    session = GISAUtils.SessionFactory.OpenSession();

            //    // Codigo e designacao
            //    NivelEntity nivel = session.Get<NivelEntity>(idNivel);
            //    if (nivel != null && nivel.Codigo != null && !nivel.IsDeleted)
            //    {
            //        this.id = nivel.Id.ToString();
            //        this.numero = nivel.Codigo;

            //        NivelDesignadoEntity nd = session.Get<NivelDesignadoEntity>(nivel.Id);
            //        if (nd != null && nd.Designacao != null && !nd.IsDeleted)
            //        {
            //            this.designacao = nd.Designacao;

            //            NivelUnidadeFisicaEntity nuf = session.Get<NivelUnidadeFisicaEntity>(nd.Id);
            //            if (nuf != null && nuf.CodigoBarras != null && !nuf.IsDeleted)
            //                this.CodigoBarras = nuf.CodigoBarras.ToString();
            //        }

            //        // Guia de incorporacao, Eliminado:
            //        NivelUnidadeFisicaEntity nufe = session.Get<NivelUnidadeFisicaEntity>(nivel.Id);
            //        if (nufe != null && !nufe.IsDeleted)
            //        {
            //            if (nufe.GuiaIncorporacao != null)
            //                this.guiaIncorporacao = nufe.GuiaIncorporacao;
            //            this.eliminado = nufe.Eliminado ? "sim" : "nao";
            //        }
            //        else
            //            this.eliminado = "nao";
            //    }

            //    long idFRDBase = -1;
            //    IQuery qFrdbase = session.CreateQuery("from FRDBaseEntity frdb WHERE frdb.Nivel.Id = " + idNivel);
            //    qFrdbase.SetTimeout(1000);
            //    FRDBaseEntity frdbase = qFrdbase.UniqueResult<FRDBaseEntity>();

            //    if (frdbase == null)
            //    {
            //        return;
            //    }

            //    idFRDBase = frdbase.Id;

            //    // Cota
            //    SFRDUFCotaEntity sfrdufc = session.Get<SFRDUFCotaEntity>(idFRDBase);
            //    if (sfrdufc != null && !sfrdufc.IsDeleted)
            //    {
            //        if (sfrdufc.Cota != null)
            //            this.cota = sfrdufc.Cota;
            //    }

            //    // Datas de producao
            //    SFRDDatasProducaoEntity sfrddp = session.Get<SFRDDatasProducaoEntity>(idFRDBase);

            //    this.dataInicioProd = GISAUtils.DataInicioProdFormatada(sfrddp);
            //    this.dataFimProd = GISAUtils.DataFimProdFormatada(sfrddp);

            //    // Conteudo informacional e guia incorporacao
            //    SFRDConteudoEEstruturaEntity sfrdcee = session.Get<SFRDConteudoEEstruturaEntity>(idFRDBase);
            //    if (sfrdcee != null && sfrdcee.ConteudoInformacional != null && !sfrdcee.IsDeleted)
            //    {
            //        this.conteudoInformacional = sfrdcee.ConteudoInformacional;
            //    }

            //    // Tipo de unidade fisica
            //    SFRDUFDescricaoFisicaEntity sfrdufdf = session.Get<SFRDUFDescricaoFisicaEntity>(idFRDBase);
            //    if (sfrdufdf != null && !sfrdufdf.IsDeleted)
            //    {
            //        TipoAcondicionamentoEntity ta = sfrdufdf.TipoAcondicionamento;
            //        if (ta != null && ta.Designacao != null && !ta.IsDeleted)
            //        {
            //            this.tipoUnidadeFisica = ta.Designacao;
            //        }
            //    }

            //    // Operador/Grupo - on the fly

            //    // Unidades arquivisticas - on the fly
            //}
            //catch (Exception) { throw; }
            //finally
            //{
            //    if (session != null) session.Close();
            //}
        }