Example #1
0
        //--------------------------------------------------------------
        public static void EditeDroits(Type type)
        {
            if (type == null)
            {
                return;
            }
            CFormEditDroitsSurType form = new CFormEditDroitsSurType();

            using (CContexteDonnee contexte = CSc2iWin32DataClient.ContexteCourant.GetContexteEdition())
            {
                CDroitEditionType droit = new CDroitEditionType(contexte);
                if (!droit.ReadIfExists(new CFiltreData(CDroitEditionType.c_champTypeElements + "=@1",
                                                        type.ToString())))
                {
                    droit.CreateNewInCurrentContexte();
                    droit.TypeElements = type;
                }
                form.m_droitSurType = droit;
                if (form.ShowDialog() == DialogResult.OK)
                {
                    CResultAErreur result = contexte.CommitEdit();
                    if (!result)
                    {
                        CFormAlerte.Afficher(result.Erreur);
                    }
                }
                else
                {
                    contexte.CancelEdit();
                }
            }
            form.Dispose();
            return;
        }
Example #2
0
        //-------------------------------------------------------------------------
        private void m_btnOK_Click(object sender, EventArgs e)
        {
            m_result = CResultAErreur.True;
            foreach (Control ctrl in m_panelControlsSaisie.Controls)
            {
                CControlSaisieNomEntite control = ctrl as CControlSaisieNomEntite;
                if (control != null)
                {
                    m_result += control.MajChamps();
                }
            }

            if (!m_result)
            {
                CFormAlerte.Afficher(m_result.Erreur);
            }
            else if (m_contexteLocal != null)
            {
                m_result = m_contexteLocal.CommitEdit();
                if (!m_result)
                {
                    CFormAlerte.Afficher(m_result.Erreur);
                }
                else
                {
                    DialogResult = DialogResult.OK;
                    Close();
                }
            }
        }
Example #3
0
        //-------------------------------------------------------------------
        private void m_lnkImportMibs_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter = I.T("Mib files (*.mib)|*.mib|All files (*.*)|*.*|20255");
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    StreamReader reader = new StreamReader(dlg.FileName, System.Text.Encoding.Default);
                    CResultAErreurType <IList <IModule> > resultModules = CSnmpMibModule.CompileFile(reader);
                    reader.Close();
                    if (resultModules)
                    {
                        using (CContexteDonnee ctx = CSc2iWin32DataClient.ContexteCourant.GetContexteEdition())
                        {
                            CListeObjetDonneeGenerique <CSnmpMibModule> lstModules = new CListeObjetDonneeGenerique <CSnmpMibModule>(ctx);
                            lstModules.AssureLectureFaite();
                            lstModules.InterditLectureInDB = true;
                            foreach (IModule module in resultModules.DataType)
                            {
                                //Cherche le module dans la liste des modules
                                lstModules.Filtre = new CFiltreData(CSnmpMibModule.c_champModuleId + "=@1",
                                                                    module.Name);
                                if (lstModules.Count == 0)
                                {
                                    CSnmpMibModule mib = new CSnmpMibModule(ctx);
                                    mib.CreateNewInCurrentContexte();
                                    mib.ModuleId  = module.Name;
                                    mib.ModuleMib = module;
                                    mib.Libelle   = module.Name;
                                }
                            }
                            CResultAErreur result = ctx.CommitEdit();
                            if (!result)
                            {
                                CFormAfficheErreur.Show(result.Erreur);
                            }
                            else
                            {
                                m_panelListe.RemplirGrille();
                            }
                        }
                    }
                    else
                    {
                        CFormAfficheErreur.Show(resultModules.Erreur);
                    }
                }
                catch (Exception ex)
                {
                    CResultAErreur result = CResultAErreur.True;
                    result.EmpileErreur(new CErreurException(ex));
                    CFormAfficheErreur.Show(result.Erreur);
                }
            }
        }
Example #4
0
 //-------------------------------------------------------------------------
 private void m_arbreCategories_DragDrop(object sender, DragEventArgs e)
 {
     if (DragDataHasDocGed(e.Data))
     {
         using (CContexteDonnee ctx = CSc2iWin32DataClient.ContexteCourant.GetContexteEdition())
         {
             bool bAddCategorie       = (e.KeyState & 8) == 8;
             TreeViewHitTestInfo info = m_arbreCategories.HitTest(m_arbreCategories.PointToClient(new Point(e.X, e.Y)));
             TreeNode            node = info.Node;
             if (info != null && info.Node != null && m_arbreCategories.GetObjetInNode(info.Node) is CCategorieGED)
             {
                 CCategorieGED categorie = m_arbreCategories.GetObjetInNode(info.Node) as CCategorieGED;
                 foreach (CReferenceObjetDonnee refDoc in (CReferenceObjetDonnee[])e.Data.GetData(typeof(CReferenceObjetDonnee[])))
                 {
                     CDocumentGED doc = refDoc.GetObjet(ctx) as CDocumentGED;
                     if (doc != null)
                     {
                         if (!bAddCategorie)//Supprime les anciennes catégories
                         {
                             CListeObjetsDonnees lst = doc.RelationsCategories;
                             CObjetDonneeAIdNumerique.Delete(lst, true);
                         }
                         bool bDedans = false;
                         foreach (CRelationDocumentGED_Categorie rel in doc.RelationsCategories)
                         {
                             if (rel.Categorie.Id == categorie.Id)
                             {
                                 bDedans = true;
                                 break;
                             }
                         }
                         if (!bDedans)
                         {
                             CRelationDocumentGED_Categorie newRel = new CRelationDocumentGED_Categorie(ctx);
                             newRel.CreateNewInCurrentContexte();
                             newRel.Categorie = categorie;
                             newRel.Document  = doc;
                         }
                     }
                 }
             }
             CResultAErreur result = ctx.CommitEdit();
             if (!result)
             {
                 CFormAfficheErreur.Show(result.Erreur);
             }
             else
             {
                 InitPanelList(m_elementSelectionne);
             }
         }
     }
     HightlightCategorie(null);
 }
Example #5
0
 //----------------------------------------------------------------
 private void m_btnOk_Click(object sender, EventArgs e)
 {
     if (m_contexteModification != null)
     {
         CResultAErreur result = m_contexteModification.CommitEdit();
         if (!result)
         {
             CFormAlerte.Afficher(result.Erreur);
             return;
         }
         DialogResult = DialogResult.OK;
         Close();
     }
 }
Example #6
0
        private void DragDropFiles(string[] strFichiers, CObjetDonneeAIdNumerique objet, CCategorieGED categorie)
        {
            CContexteDonnee ctxAppli = CSc2iWin32DataClient.ContexteCourant;

            using (CContexteDonnee contexte = ctxAppli.GetContexteEdition())
            {
                if (MessageBox.Show(m_lblInfoDragDrop.Text, "", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    foreach (string strFichier in strFichiers)
                    {
                        if (File.Exists(strFichier))
                        {
                            string strTitre = Path.GetFileName(strFichier);
                            string strExt   = Path.GetExtension(strFichier);
                            if (strExt.Length > 0)
                            {
                                strTitre = strTitre.Remove(strTitre.Length - strExt.Length);
                            }
                            CDocumentGED document = new CDocumentGED(contexte);
                            document.CreateNewInCurrentContexte();
                            document.Libelle = strTitre;
                            if (objet != null)
                            {
                                document.AssocieA(objet);
                            }
                            if (categorie != null)
                            {
                                CRelationDocumentGED_Categorie rel = new CRelationDocumentGED_Categorie(contexte);
                                rel.CreateNewInCurrentContexte();
                                rel.Categorie = categorie;
                                rel.Document  = document;
                            }
                            CTypeReferenceDocument typeRef = m_cmbModeStockage.SelectedValue as CTypeReferenceDocument;
                            if (typeRef == null)
                            {
                                typeRef = new CTypeReferenceDocument(CTypeReferenceDocument.TypesReference.Fichier);
                            }
                            CProxyGED proxy = new CProxyGED(contexte.IdSession, typeRef.Code);
                            proxy.AttacheToLocal(strFichier);
                            CResultAErreur result = proxy.UpdateGed();
                            document.ReferenceDoc = result.Data as CReferenceDocument;
                        }
                    }
                    contexte.CommitEdit();
                    Init(m_elementEdite);
                }
            }
            m_lblInfoDragDrop.Visible = false;
        }
Example #7
0
        private void m_lnkDissocierElementEnCours_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (m_elementSelectionne != null)
            {
                List <string> listeIdsDocuments = new List <string>();
                foreach (CDocumentGED document in m_panelListDocumentsGED.ElementsSelectionnes)
                {
                    listeIdsDocuments.Add(document.Id.ToString());
                }
                int nbSelectionne = listeIdsDocuments.Count();
                if (nbSelectionne == 0)
                {
                    CFormAlerte.Afficher(I.T("No Document selected to dissociate|10334"));
                }
                else
                {
                    DialogResult reponse = CFormAlerte.Afficher(I.T("Dissociate @1 document(s) from '@2'. Do you Confirm?|10335", nbSelectionne.ToString(), m_elementSelectionne.DescriptionElement), EFormAlerteType.Question);
                    if (reponse == DialogResult.Yes)
                    {
                        using (CContexteDonnee ctx = CSc2iWin32DataClient.ContexteCourant.GetContexteEdition())
                        {
                            CListeObjetsDonnees listeRelationsASupprimer = new CListeObjetsDonnees(ctx, typeof(CRelationElementToDocument));
                            listeRelationsASupprimer.Filtre = new CFiltreData(
                                CRelationElementToDocument.c_champTypeElement + " = @1 AND " +
                                CRelationElementToDocument.c_champIdElement + " = @2 AND " +
                                CDocumentGED.c_champId + " in (" + string.Join(",", listeIdsDocuments.ToArray()) + ")",
                                m_elementSelectionne.GetType().ToString(),
                                m_elementSelectionne.Id);

                            if (listeRelationsASupprimer.Count > 0)
                            {
                                CObjetDonneeAIdNumerique.Delete(listeRelationsASupprimer, true);
                            }

                            CResultAErreur result = ctx.CommitEdit();
                            if (!result)
                            {
                                CFormAlerte.Afficher(result.Erreur);
                            }
                            else
                            {
                                InitPanelList(m_elementSelectionne);
                            }
                        }
                    }
                }
            }
        }
Example #8
0
 //----------------------------------------------------
 public void UpdateAgentIpFromMediation(string strAgentId, string strNewIp, bool bUpdateTimosDb)
 {
     if (bUpdateTimosDb)
     {
         AssureSessionEtContexte();
         int nIdAgent = -1;
         if (Int32.TryParse(strAgentId, out nIdAgent) && m_contexteDonnee != null)
         {
             using (CContexteDonnee ctxEdit = m_contexteDonnee.GetContexteEdition())
             {
                 CAgentSnmp agent = new CAgentSnmp(ctxEdit);
                 if (agent.ReadIfExists(nIdAgent))
                 {
                     agent.SnmpIp = strNewIp;
                     ctxEdit.EnableTraitementsAvantSauvegarde = false;
                     ctxEdit.EnableTraitementsExternes        = false;
                     ctxEdit.CommitEdit();
                 }
             }
         }
     }
 }
Example #9
0
        //----------------------------------------------------------------
        private bool OnClickValider()
        {
            CResultAErreur result = CResultAErreur.True;
            CObjetDonnee   objet  = m_objetEdite as CObjetDonnee;

            if (objet != null)
            {
                result = m_createur.MAJ_Champs();
                if (result)
                {
                    result = objet.VerifieDonnees(true);
                }
                if (result)
                {
                    result = objet.CommitEdit();
                }
            }
            else
            {
                if (m_contexteEdition != null)
                {
                    result = m_contexteEdition.CommitEdit();
                }
            }
            if (!result)
            {
                CFormAlerte.Afficher(result.Erreur);
                return(false);
            }
            else
            {
                m_contexteEdition            = null;
                m_extModeEdition.ModeEdition = false;
                m_createur.LockEdition       = true;
                m_createur.ElementEdite      = m_objetEdite;
            }
            return(true);
        }
Example #10
0
 //------------------------------------------
 private void m_picBox_DragDrop(object sender, DragEventArgs e)
 {
     CReferenceObjetDonnee[] refs = e.Data.GetData(typeof(CReferenceObjetDonnee[])) as CReferenceObjetDonnee[];
     if (refs == null)
     {
         CReferenceObjetDonnee refe = e.Data.GetData(typeof(CReferenceObjetDonnee)) as CReferenceObjetDonnee;
         if (refe != null)
         {
             refs = new CReferenceObjetDonnee[] { refe };
         }
     }
     if (refs != null)
     {
         List <CBesoin> lstBesoins = new List <CBesoin>();
         StringBuilder  blListe    = new StringBuilder();
         foreach (CReferenceObjetDonnee refO in refs)
         {
             if (typeof(CBesoin).IsAssignableFrom(refO.TypeObjet))
             {
                 CBesoin besoin = refO.GetObjet(m_satisfaction.ContexteDonnee) as CBesoin;
                 if (besoin != null)
                 {
                     if (m_satisfaction.CanSatisfaire(besoin))
                     {
                         lstBesoins.Add(besoin);
                         blListe.Append(besoin.Libelle);
                         blListe.Append(" ,");
                     }
                 }
             }
         }
         if (lstBesoins.Count > 0)
         {
             blListe.Remove(blListe.Length - 2, 2);
             if (MessageBox.Show(I.T("@1 will be considered as a solution of @2. Continue ?|20631",
                                     m_satisfaction.Libelle, blListe.ToString()), "",
                                 MessageBoxButtons.YesNo,
                                 MessageBoxIcon.Question) == DialogResult.Yes)
             {
                 CContexteDonnee ctx = m_satisfaction.ContexteDonnee;
                 if (!m_bIsEnEdition)
                 {
                     ctx = ctx.GetContexteEdition();
                 }
                 foreach (CBesoin besoin in lstBesoins)
                 {
                     CBesoin besoinEdit = besoin.GetObjetInContexte(ctx) as CBesoin;
                     besoinEdit.AddSatisfaction(m_satisfaction, null);
                 }
                 if (!m_bIsEnEdition)
                 {
                     CResultAErreur result = ctx.CommitEdit();
                     if (!result)
                     {
                         CFormAlerte.Afficher(result.Erreur);
                         ctx.CancelEdit();
                     }
                     ctx.Dispose();
                 }
             }
         }
     }
 }
Example #11
0
        private void m_arbreConsultation_DragDrop(object sender, DragEventArgs e)
        {
            if (DragDataHasDocGed(e.Data))
            {
                using (CContexteDonnee ctx = CSc2iWin32DataClient.ContexteCourant.GetContexteEdition())
                {
                    bool bAddElement         = (e.KeyState & 8) == 8;
                    TreeViewHitTestInfo info = m_arbreConsultation.HitTest(m_arbreConsultation.PointToClient(new Point(e.X, e.Y)));
                    TreeNode            node = info.Node;
                    if (info != null && info.Node != null && info.Node.Tag is CNodeConsultationHierarchique &&
                        ((CNodeConsultationHierarchique)info.Node.Tag).ObjetLie is CObjetDonneeAIdNumerique)
                    {
                        CObjetDonneeAIdNumerique objetAId = ((CNodeConsultationHierarchique)info.Node.Tag).ObjetLie as CObjetDonneeAIdNumerique;
                        foreach (CReferenceObjetDonnee refDoc in (CReferenceObjetDonnee[])e.Data.GetData(typeof(CReferenceObjetDonnee[])))
                        {
                            CDocumentGED doc = refDoc.GetObjet(ctx) as CDocumentGED;
                            if (doc != null)
                            {
                                if (!bAddElement)//Supprime les anciennes catégories
                                {
                                    StringBuilder bl = new StringBuilder();
                                    foreach (CRelationElementToDocument rel in doc.RelationsElements)
                                    {
                                        if (rel.ElementLie != null)
                                        {
                                            bl.Append("-");
                                            bl.Append(rel.ElementLie.DescriptionElement);
                                            bl.Append(System.Environment.NewLine);
                                        }
                                    }
                                    if (bl.Length > 0)
                                    {
                                        if (CFormAlerte.Afficher(I.T("This operation will remove association to \r\n@1 and add an association to @2. Continue ?|20475",
                                                                     bl.ToString(),
                                                                     objetAId.DescriptionElement), EFormAlerteType.Question) == DialogResult.No)
                                        {
                                            HightlightElementDeArbre(null);
                                            e.Effect = DragDropEffects.None;
                                            return;
                                        }
                                    }


                                    CListeObjetsDonnees lst = doc.RelationsElements;
                                    CObjetDonneeAIdNumerique.Delete(lst, true);
                                }
                                doc.AssocieA(objetAId);
                            }
                        }
                    }
                    CResultAErreur result = ctx.CommitEdit();
                    if (!result)
                    {
                        CFormAlerte.Afficher(result.Erreur);
                    }
                    else
                    {
                        InitPanelList(m_elementSelectionne);
                    }
                }
            }
            HightlightElementDeArbre(null);
        }