コード例 #1
0
        private void AcceptNivelRow(GISADataset.NivelRow NivelRow)
        {
            // aceitar o drop apenas se se tratar de uma UF ainda não associada
            var nufRow  = NivelRow.GetNivelDesignadoRows()[0].GetNivelUnidadeFisicaRows()[0];
            var ufs     = GetUFInfo(NivelRow);
            var nufdRow = nufRow.GetNivelUnidadeFisicaDepositoRows().SingleOrDefault();

            if (nufdRow == null)
            {
                nufdRow = GisaDataSetHelper.GetInstance().NivelUnidadeFisicaDeposito.NewNivelUnidadeFisicaDepositoRow();
                nufdRow.NivelUnidadeFisicaRow = nufRow;
                nufdRow.DepositoRow           = CurrentDeposito;
                nufdRow.Versao    = new byte[] {};
                nufdRow.isDeleted = 0;
                GisaDataSetHelper.GetInstance().NivelUnidadeFisicaDeposito.AddNivelUnidadeFisicaDepositoRow(nufdRow);
                PopulateAssociacoes(ufs);
                ufsAssociadas.Add(ufs.ToList().Single());
            }
            else if (nufdRow.IDDeposito != CurrentDeposito.ID)
            {
                // ToDo: deixa-se substituir?
            }
            else if (nufdRow.IDDeposito == CurrentDeposito.ID && !ufsAssociadas.Contains(ufs.ToList().Single()))
            {
                PopulateAssociacoes(ufs);
                ufsAssociadas.Add(ufs.ToList().Single());
            }
        }
コード例 #2
0
        public void ViewToModel(Contexto viewMode, bool disableSave)
        {
            var tnrID = currentNivel.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica().First().IDTipoNivelRelacionado;

            if (viewMode == ObjetoDigitalFedoraHelper.Contexto.imagens)
            {
                // neste modo, o contexto é sempre um subdocumento e como tal tem que se ter em consideração informação sobre o subdocumento e o seu documento/processo
                Trace.Assert(tnrID == (long)TipoNivelRelacionado.SD);

                var repoName  = SessionHelper.AppConfiguration.GetCurrentAppconfiguration().FedoraHelperSingleton.GetRepositoryName();
                var imgVolRow = FedoraHelper.GetRepositoryImagemVolumeRow();

                Debug.Assert(currentODSimples.Count <= 1); // no contexto de um subdocumento só pode haver 1 OD no máximo
                if (currentODSimples.Count == 1)
                {
                    var odSimples = currentODSimples[0];
                    if (odSimples.state == State.added)
                    {
                        var frdRow = currentNivel.GetFRDBaseRows().Single();
                        odSimples.gisa_id = FedoraHelper.gisaPrefix + currentNivel.ID;

                        var idxTip = frdRow.GetIndexFRDCARows().SingleOrDefault(idx => idx["Selector"] != DBNull.Value && idx.Selector == -1);
                        if (idxTip != null)
                        {
                            odSimples.tipologia = idxTip.ControloAutRow.GetControloAutDicionarioRows().Single(cad => cad.IDTipoControloAutForma == (long)TipoControloAutForma.FormaAutorizada).DicionarioRow.Termo;
                        }

                        var assuntos = frdRow.GetIndexFRDCARows().Where(idx => idx.ControloAutRow.IDTipoNoticiaAut < 4).SelectMany(idx => idx.ControloAutRow.GetControloAutDicionarioRows()).Where(cad => cad.IDTipoControloAutForma == (long)TipoControloAutForma.FormaAutorizada).Select(cad => cad.DicionarioRow.Termo);
                        if (assuntos.Count() > 0)
                        {
                            odSimples.assuntos = assuntos.ToList();
                        }

                        var imgRow = GisaDataSetHelper.GetInstance().SFRDImagem.NewSFRDImagemRow();
                        imgRow.Identificador       = "";
                        imgRow.FRDBaseRow          = frdRow;
                        imgRow.Tipo                = FedoraHelper.typeFedora;
                        imgRow.Versao              = new byte[] { };
                        imgRow.isDeleted           = 0;
                        imgRow.GUIOrder            = long.MaxValue;
                        imgRow.Descricao           = "";
                        imgRow.SFRDImagemVolumeRow = imgVolRow;
                        GisaDataSetHelper.GetInstance().SFRDImagem.AddSFRDImagemRow(imgRow);

                        if (currentODComp != null)
                        {
                            Debug.Assert(currentObjetoDigitalRowComp != null);

                            var nUpperRow = currentNivel.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica().Single().NivelRowByNivelRelacaoHierarquicaUpper;
                            odSimples.parentDocumentTitle = nUpperRow.GetNivelDesignadoRows().Single().Designacao;
                            var orderNr = currentNivel.GetNivelDesignadoRows().Single().GetNivelDocumentoSimplesRows().Single().GUIOrder;
                            odSimples.guiorder      = orderNr;
                            currentObjetoDigitalRow = GisaDataSetHelper.GetInstance().ObjetoDigital.AddObjetoDigitalRow(odSimples.pid, odSimples.titulo, odSimples.publicado, orderNr, new byte[] { }, 0);
                            GisaDataSetHelper.GetInstance().ObjetoDigitalRelacaoHierarquica.AddObjetoDigitalRelacaoHierarquicaRow(currentObjetoDigitalRow, currentObjetoDigitalRowComp, new byte[] { }, 0);

                            currentODComp.objSimples.Insert((int)odSimples.guiorder - 1, odSimples);
                        }
                        else
                        {
                            var ndsRow = currentNivel.GetNivelDesignadoRows().Single().GetNivelDocumentoSimplesRows().Single();
                            currentObjetoDigitalRow = GisaDataSetHelper.GetInstance().ObjetoDigital.AddObjetoDigitalRow(odSimples.pid, odSimples.titulo, odSimples.publicado, ndsRow.GUIOrder, new byte[] { }, 0);
                        }

                        GisaDataSetHelper.GetInstance().SFRDImagemObjetoDigital.AddSFRDImagemObjetoDigitalRow(imgRow.IDFRDBase, imgRow.idx, currentObjetoDigitalRow, new byte[] { }, 0);
                        //PermissoesHelper.AddNewObjDigGrantPermissions(currentObjetoDigitalRow, currentNivel);
                        newObjects.Add(currentObjetoDigitalRow, odSimples);
                    }
                    else if (odSimples.state == State.modified)
                    {
                        currentObjetoDigitalRow.Titulo    = odSimples.titulo;
                        currentObjetoDigitalRow.Publicado = odSimples.publicado;

                        if (currentODComp != null)
                        {
                            currentObjetoDigitalRowComp.Publicado = currentODComp.publicado;
                        }
                    }
                    else if (odSimples.state == State.deleted)
                    {
                        FedoraHelper.DeleteObjDigitalRows(currentObjetoDigitalRow);
                        if (currentODComp != null && currentODComp.state == State.deleted)
                        {
                            FedoraHelper.DeleteObjDigitalRows(currentObjetoDigitalRowComp);
                        }
                    }
                }
            }
            else if (mContexto == ObjetoDigitalFedoraHelper.Contexto.objetosDigitais)
            {
                if (disableSave)
                {
                    return;
                }

                if (currentODComp != null) // caso onde existe um OD composto associado à UI
                {
                    var odRowComp = default(GISADataset.ObjetoDigitalRow);
                    switch (currentODComp.state)
                    {
                    case State.added:
                        currentODComp.gisa_id = FedoraHelper.gisaPrefix + currentNivel.ID;
                        var frdRow    = currentNivel.GetFRDBaseRows().Single();
                        var imgVolRow = FedoraHelper.GetRepositoryImagemVolumeRow();
                        var imgRow    = GisaDataSetHelper.GetInstance().SFRDImagem.NewSFRDImagemRow();
                        imgRow.Identificador       = "";
                        imgRow.FRDBaseRow          = frdRow;
                        imgRow.Tipo                = FedoraHelper.typeFedora;
                        imgRow.Versao              = new byte[] { };
                        imgRow.isDeleted           = 0;
                        imgRow.GUIOrder            = long.MaxValue;
                        imgRow.Descricao           = "";
                        imgRow.SFRDImagemVolumeRow = imgVolRow;
                        GisaDataSetHelper.GetInstance().SFRDImagem.AddSFRDImagemRow(imgRow);

                        currentObjetoDigitalRowComp = GisaDataSetHelper.GetInstance().ObjetoDigital.AddObjetoDigitalRow(currentODComp.pid, currentODComp.titulo, currentODComp.publicado, 1, new byte[] { }, 0);
                        GisaDataSetHelper.GetInstance().SFRDImagemObjetoDigital.AddSFRDImagemObjetoDigitalRow(imgRow.IDFRDBase, imgRow.idx, currentObjetoDigitalRowComp, new byte[] { }, 0);

                        //PermissoesHelper.AddNewObjDigGrantPermissions(currentObjetoDigitalRowComp, currentNivel);

                        newObjects.Add(currentObjetoDigitalRowComp, currentODComp);

                        var idxTip = frdRow.GetIndexFRDCARows().SingleOrDefault(idx => idx["Selector"] != DBNull.Value && idx.Selector == -1);
                        if (idxTip != null)
                        {
                            currentODComp.tipologia = idxTip.ControloAutRow.GetControloAutDicionarioRows().Single(cad => cad.IDTipoControloAutForma == (long)TipoControloAutForma.FormaAutorizada).DicionarioRow.Termo;
                        }

                        var assuntos = frdRow.GetIndexFRDCARows().Where(idx => idx.ControloAutRow.IDTipoNoticiaAut < 4).SelectMany(idx => idx.ControloAutRow.GetControloAutDicionarioRows()).Where(cad => cad.IDTipoControloAutForma == (long)TipoControloAutForma.FormaAutorizada).Select(cad => cad.DicionarioRow.Termo);
                        if (assuntos.Count() > 0)
                        {
                            currentODComp.assuntos = assuntos.ToList();
                        }

                        break;

                    case State.modified:
                        currentObjetoDigitalRowComp.Titulo    = currentODComp.titulo;
                        currentObjetoDigitalRowComp.Publicado = currentODComp.publicado;
                        break;

                    case State.deleted:
                        FedoraHelper.DeleteObjDigitalRows(currentObjetoDigitalRowComp);
                        break;
                    }

                    odRowComp = currentObjetoDigitalRowComp;

                    ViewToModelObjsSimples(currentODComp.objSimples, currentODComp, odRowComp);
                }
                else // caso onde só existem ODs simples soltos associados à UI
                {
                    ViewToModelObjsSimples(currentODSimples);
                }
            }


            // atribuir permissões aos objectos digitais novos
            var odRows = GisaDataSetHelper.GetInstance().ObjetoDigital.Cast <GISADataset.ObjetoDigitalRow>().Where(r => r.RowState == DataRowState.Added).ToList();

            PermissoesHelper.AddNewObjDigGrantPermissions(odRows, currentNivel);

            // atribuir permissão de leitura ao grupo publicados consoante o valor da flag publicado definida nas datarows GISADataset.ObjetoDigitalRow que foram adicionadas ou editadas
            GisaDataSetHelper.GetInstance().ObjetoDigital.Cast <GISADataset.ObjetoDigitalRow>().Where(r => r.RowState == DataRowState.Added || r.RowState == DataRowState.Modified).ToList()
            .ForEach(odRow => PermissoesHelper.ChangeObjDigPermissionPublicados(odRow));

            // actualizar ordem dos subdocumentos sem objeto digital
            docSimplesSemOD.ForEach(docSimples => docSimples.nRow.GetNivelDesignadoRows().Single().GetNivelDocumentoSimplesRows().Single().GUIOrder = docSimples.guiorder);
        }
コード例 #3
0
        private void AddDetalhe(GISADataset.NivelRow nRow, string nCod)
        {
            if (detalhes[nRow.ID] == null)
            {
                ArrayList aux = new ArrayList();
                GISADataset.SFRDDatasProducaoRow sfrddprow = null;
                string ia = null;
                string im = null;
                string id = null;
                string fa = null;
                string fm = null;
                string fd = null;

                if (nRow.GetFRDBaseRows()[0].GetSFRDDatasProducaoRows().Length > 0)
                {
                    sfrddprow = (GISADataset.SFRDDatasProducaoRow)(nRow.GetFRDBaseRows()[0].GetSFRDDatasProducaoRows()[0]);

                    if (sfrddprow.IsInicioAnoNull())
                    {
                        ia = "";
                    }
                    else
                    {
                        ia = sfrddprow.InicioAno;
                    }

                    if (sfrddprow.IsInicioMesNull())
                    {
                        im = "";
                    }
                    else
                    {
                        im = sfrddprow.InicioMes;
                    }

                    if (sfrddprow.IsInicioDiaNull())
                    {
                        id = "";
                    }
                    else
                    {
                        id = sfrddprow.InicioDia;
                    }

                    if (sfrddprow.IsFimAnoNull())
                    {
                        fa = "";
                    }
                    else
                    {
                        fa = sfrddprow.FimAno;
                    }

                    if (sfrddprow.IsFimMesNull())
                    {
                        fm = "";
                    }
                    else
                    {
                        fm = sfrddprow.FimMes;
                    }

                    if (sfrddprow.IsFimDiaNull())
                    {
                        fd = "";
                    }
                    else
                    {
                        fd = sfrddprow.FimDia;
                    }
                }
                else
                {
                    ia = "";
                    im = "";
                    id = "";
                    fa = "";
                    fm = "";
                    fd = "";
                }

                GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection());
                try
                {
                    if (nRow.IDTipoNivel == 3)
                    {
                        aux.Add(nRow.GetNivelDesignadoRows()[0].Designacao);
                    }
                    else
                    {
                        DBAbstractDataLayer.DataAccessRules.NivelRule.Current.FillNivelControloAutRows(GisaDataSetHelper.GetInstance(), nRow.ID, ho.Connection);

                        if (nRow.GetNivelControloAutRows().Length > 0)
                        {
                            aux.Add(nRow.GetNivelControloAutRows()[0].ControloAutRow.GetControloAutDicionarioRows()[0].DicionarioRow.Termo);
                        }
                        else if (nRow.GetNivelDesignadoRows().Length > 0)
                        {
                            aux.Add(nRow.GetNivelDesignadoRows()[0].Designacao);
                        }
                    }

                    aux.Add(nRow.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica()[0].TipoNivelRelacionadoRow.ID);
                    aux.Add(ia);
                    aux.Add(im);
                    aux.Add(id);
                    aux.Add(fa);
                    aux.Add(fm);
                    aux.Add(fd);
                    aux.Add(nCod);
                    aux.Add("1"); // Se aparece aqui é porque temos permissao...

                    if (MovimentoRule.Current.estaRequisitado(nRow.ID, ho.Connection))
                    {
                        aux.Add(true);
                    }
                    else
                    {
                        aux.Add(false);
                    }
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(ex);
                    throw;
                }
                finally
                {
                    ho.Dispose();
                }

                detalhes.Add(nRow.ID, aux);
            }
        }
コード例 #4
0
ファイル: Nivel.cs プロジェクト: huguitosilva1/gisa
		private static string GetDesignacaoInDataSet(GISADataset.NivelRow Nivel)
		{
			bool nivelOrganico = isNivelOrganico(Nivel);
			GisaDataSetHelper.HoldOpen ho = null;
			if (! nivelOrganico)
			{
				if (Nivel.GetNivelDesignadoRows().Length == 0)
				{
					ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection());
					try
					{
						NivelRule.Current.FillNivelDesignado(GisaDataSetHelper.GetInstance(), Nivel.ID, ho.Connection);
					}
					catch (Exception ex)
					{
						Trace.WriteLine(ex);
						throw;
					}
					finally
					{
						ho.Dispose();
					}
				}
				Debug.Assert(Nivel.GetNivelDesignadoRows().Length > 0);
				return Nivel.GetNivelDesignadoRows()[0].Designacao;
			}
			if (nivelOrganico)
			{
				if (Nivel.GetNivelControloAutRows().Length == 0 || 
					Nivel.GetNivelControloAutRows()[0].ControloAutRow.GetControloAutDicionarioRows().Length == 0)
				{
					ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection());
					try
					{
						NivelRule.Current.FillNivelControloAutRows(GisaDataSetHelper.GetInstance(), Nivel.ID, ho.Connection);
					}
					catch (Exception ex)
					{
						Trace.WriteLine(ex);
						throw;
					}
					finally
					{
						ho.Dispose();
					}
				}
				Debug.Assert(Nivel.GetNivelControloAutRows().Length > 0);
				Debug.Assert(Nivel.GetNivelControloAutRows()[0].ControloAutRow.GetControloAutDicionarioRows().Length > 0);
				foreach (GISADataset.ControloAutDicionarioRow cad in Nivel.GetNivelControloAutRows()[0].ControloAutRow.GetControloAutDicionarioRows())
				{
					if (cad.IDTipoControloAutForma == (long)TipoControloAutForma.FormaAutorizada)
					{
						return cad.DicionarioRow.Termo;
					}
				}
			}
#if (DEBUG)
			Debug.WriteLine("Nivel ID=", Nivel.ID.ToString());
			Debug.WriteLine("Nivel IDTipoNivel=", Nivel.IDTipoNivel.ToString());
			throw new ArgumentException("details not found in Nivel.Table.DataSet", "Nivel");
#else
			{
			Console.WriteLine("details not found in Nivel.Table.DataSet / Tipo=" + Nivel.IDTipoNivel.ToString());
			return "";
			}
#endif
		}