示例#1
0
        //--------------------------------------------------------------------------------------
        public static CDictionnaireTypeEditeTypeFormPrefere GetInstance()
        {
            if (m_dictionnaire == null)
            {
                // Lit le registre
                CDataBaseRegistrePourClient registre = new CDataBaseRegistrePourClient(CSc2iWin32DataClient.ContexteCourant.IdSession);
                if (registre != null)
                {
                    byte[] data = registre.GetValeurBlob(c_cleRegistre);
                    if (data != null)
                    {
                        MemoryStream           flux       = new MemoryStream(data);
                        BinaryReader           lecteur    = new BinaryReader(flux);
                        CSerializerReadBinaire serializer = new CSerializerReadBinaire(lecteur);
                        CResultAErreur         result     = serializer.TraiteObject <CDictionnaireTypeEditeTypeFormPrefere>(ref m_dictionnaire);
                        lecteur.Close();
                        flux.Close();

                        if (result)
                        {
                            return(m_dictionnaire);
                        }
                    }
                }
                m_dictionnaire = new CDictionnaireTypeEditeTypeFormPrefere();
            }
            return(m_dictionnaire);
        }
        //--------------------------------------------------------------------------
        public static C2iExpression GetFormule(int nIdSession, string strKey)
        {
            AssureRecepteurNotifications(nIdSession);
            C2iExpression formule = null;

            if (m_cacheFormule.TryGetValue(strKey, out formule))
            {
                return(formule);
            }
            CDataBaseRegistrePourClient reg = new CDataBaseRegistrePourClient(nIdSession);

            byte[] bts = reg.GetValeurBlob("GLOBFOR_" + strKey);
            if (bts != null)
            {
                MemoryStream           stream = new MemoryStream(bts);
                BinaryReader           reader = new BinaryReader(stream);
                CSerializerReadBinaire ser    = new CSerializerReadBinaire(reader);
                CResultAErreur         result = ser.TraiteObject <C2iExpression>(ref formule);
                if (result)
                {
                    m_cacheFormule[strKey] = formule;
                }
                reader.Close();
                stream.Close();
                stream.Dispose();
            }
            return(formule);
        }
 private void m_btnPaste_Click(object sender, EventArgs e)
 {
     byte[] data = Clipboard.GetData(typeof(CBlocWorkflowFormulaire).ToString()) as byte[];
     if (data != null)
     {
         try
         {
             MemoryStream           stream = new MemoryStream(data);
             BinaryReader           reader = new BinaryReader(stream);
             CSerializerReadBinaire ser    = new CSerializerReadBinaire(reader);
             ser.IsForClone = true;
             CBlocWorkflowFormulaire bloc = new CBlocWorkflowFormulaire();
             if (ser.TraiteObject <CBlocWorkflowFormulaire>(ref bloc))
             {
                 CBlocWorkflowFormulaire old = m_blocFormulaire;
                 m_blocFormulaire = bloc;
                 InitChamps();
                 m_blocFormulaire = old;
             }
             reader.Close();
             stream.Close();
             stream.Dispose();
         }
         catch { }
     }
 }
示例#4
0
        /// <summary>
        /// mutualise la récupération des formules
        /// </summary>
        /// <param name="strChampCache"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        private C2iExpression GetFormule(string strChampCache, CDonneeBinaireInRow data)
        {
            C2iExpression formule = null;

            if (Row[strChampCache] != DBNull.Value)
            {
                return((C2iExpression)Row[strChampCache]);
            }
            if (data != null && data.Donnees != null)
            {
                Stream stream = new MemoryStream(data.Donnees);
                try
                {
                    BinaryReader           reader = new BinaryReader(stream);
                    CSerializerReadBinaire ser    = new CSerializerReadBinaire(reader);
                    CResultAErreur         result = ser.TraiteObject <C2iExpression>(ref formule);
                    if (!result)
                    {
                        formule = null;
                    }
                    else
                    {
                        CContexteDonnee.ChangeRowSansDetectionModification(Row.Row, strChampCache, formule);
                    }
                    reader.Close();
                    stream.Close();
                }
                catch
                {
                }
            }
            return(formule);
        }
示例#5
0
        public static object GetValeur(
            DataRow row,
            string strChampString,
            string strChampBlob,
            string strChampType,
            CContexteDonnee ctx)
        {
            Type t = CActivatorSurChaine.GetType((string)row[strChampType]);

            if (t == typeof(IDifferencesBlob))
            {
                CDonneeBinaireInRow    blob       = GetBlob(row, strChampBlob, ctx);
                MemoryStream           stream     = new MemoryStream(blob.Donnees);
                BinaryReader           reader     = new BinaryReader(stream);
                CSerializerReadBinaire serializer = new CSerializerReadBinaire(reader);
                I2iSerializable        objet      = null;
                CResultAErreur         result     = serializer.TraiteObject(ref objet);

                reader.Close();
                stream.Close();

                if (result)
                {
                    return(objet);
                }
                System.Console.WriteLine(I.T("Error while deserializing blob diffs|30000"));
                return(null);
            }
            else if (t == typeof(byte[]))
            {
                CDonneeBinaireInRow blob = GetBlob(row, strChampBlob, ctx);
                if (blob != null)
                {
                    return(blob.Donnees);
                }
                else
                {
                    return(null);
                }
            }
            else if (typeof(CObjetDonneeAIdNumerique).IsAssignableFrom(t))
            {
                int nId = Int32.Parse((string)row[strChampString]);
                CObjetDonneeAIdNumerique obj = (CObjetDonneeAIdNumerique)Activator.CreateInstance(t, new object[] { ctx });
                if (obj.ReadIfExists(nId))
                {
                    return(obj);
                }
                return(null);
            }
            else if (t != null && row[strChampString] != DBNull.Value)
            {
                return(CUtilTexte.FromUniversalString((string)row[strChampString], t));
            }
            return(null);
        }
示例#6
0
        //--------------------------------------------
        public CValiseEntiteDeMemoryDb(SerializationInfo info, StreamingContext context)
        {
            byte[] serVal = (byte[])info.GetValue(c_cleDataSerialize, typeof(byte[]));
            if (serVal == null || serVal.Length == 0)
            {
                return;
            }
            MemoryStream           stream     = new MemoryStream(serVal);
            BinaryReader           reader     = new BinaryReader(stream);
            CMemoryDb              memDb      = new CMemoryDb();
            CSerializerReadBinaire serializer = new CSerializerReadBinaire(reader);
            CResultAErreur         result     = serializer.TraiteObject <CEntiteDeMemoryDb>(ref m_entite, new object[] { memDb });

            reader.Close();
            stream.Close();
        }
        public static CResultAErreur Paste(ref I2iSerializable objet, string strSignatureFichier)
        {
            CResultAErreur result = CResultAErreur.True;
            IDataObject    data   = Clipboard.GetDataObject( );

            if (data == null || !data.GetDataPresent(strSignatureFichier))
            {
                result.EmpileErreur(I.T("Nothing to paste|30049"));
                return(result);
            }
            byte[]                 buffer     = (byte[])data.GetData(strSignatureFichier);
            MemoryStream           stream     = new MemoryStream(buffer);
            BinaryReader           reader     = new BinaryReader(stream);
            CSerializerReadBinaire serializer = new CSerializerReadBinaire(reader);

            serializer.IsForClone = true;
            result = serializer.TraiteObject(ref objet);
            reader.Close();
            stream.Close();
            return(result);
        }
示例#8
0
        public void ShowFormulaire()
        {
            using (C2iSponsor sponsor = new C2iSponsor())
            {
                sponsor.Register(m_structure);
                CResultAErreur result = CResultAErreur.True;

                //Fait passer le formulaire par le réseau
                byte[]                 dataFormulaire = m_actionExport.GetDataSerialisationFormulairePourClient();
                MemoryStream           stream         = new MemoryStream(dataFormulaire);
                BinaryReader           reader         = new BinaryReader(stream);
                CSerializerReadBinaire serializer     = new CSerializerReadBinaire(reader);
                serializer.AttacheObjet(typeof(IElementAVariablesDynamiquesBase), m_structure);
                I2iSerializable formulaireSer = null;
                result = serializer.TraiteObject(ref formulaireSer);

                reader.Close();
                stream.Close();

                if (!result)
                {
                    m_resultForm.EmpileErreur(I.T("Error while retrieving the form|30253"));
                }

                C2iWnd formulaire = (C2iWnd)formulaireSer;

                CFormFormulairePopup form = new CFormFormulairePopup();

                if (form.EditeElement(CTimosApp.Navigateur, formulaire, m_structure, I.T("Exporting data|10046")))
                {
                    m_resultForm      = CResultAErreur.True;
                    m_resultForm.Data = E2iDialogResult.OK;
                }
                else
                {
                    m_resultForm.Data = E2iDialogResult.Cancel;
                }
            }
        }
示例#9
0
        private CResultAErreur SafeExecuteAction(C2iSponsor sponsor, ref CResultAErreur result, ref DialogResult dialogResult)
        {
            bool bBoucle = true;

            while (bBoucle)
            {
                bBoucle = false;
                CCreateur2iFormulaireV2 createur = new CCreateur2iFormulaireV2();
                //Fait passer le formulaire par le réseau
                byte[]                 dataFormulaire = m_actionFormulaire.GetDataSerialisationFormulairePourClient();
                MemoryStream           stream         = new MemoryStream(dataFormulaire);
                BinaryReader           reader         = new BinaryReader(stream);
                CSerializerReadBinaire serializer     = new CSerializerReadBinaire(reader);
                serializer.AttacheObjet(typeof(IElementAVariablesDynamiquesBase), m_actionFormulaire.Process);
                I2iSerializable formulaireSer = null;
                result = serializer.TraiteObject(ref formulaireSer);

                reader.Close();
                stream.Close();

                if (!result)
                {
                    result.EmpileErreur(I.T("Error while retrieving the form|30253"));
                    return(result);
                }
                C2iWnd formulaire = (C2iWnd)formulaireSer;

                createur.CreateControlePrincipalEtChilds(m_panelFormulaire, formulaire, m_actionFormulaire.Process);
                createur.ControleValeursAvantValidation = true;
                CProxyElementAVariables proxy = m_actionFormulaire.Process.GetProxyElementAVariables(sponsor);
                proxy.ContexteDonneeLocal = sc2i.win32.data.CSc2iWin32DataClient.ContexteCourant;

                createur.ElementEdite = proxy;

                foreach (IVariableDynamique varDyn in m_actionFormulaire.Process.ListeVariables)
                {
                    sponsor.Register(varDyn);
                }

                Size szFormulaire = formulaire.Size;
                Size szOldPanel   = m_panelFormulaire.Size;
                Size newSizeThis  = Size;
                newSizeThis.Width  = Size.Width - szOldPanel.Width + szFormulaire.Width;
                newSizeThis.Height = Size.Height - szOldPanel.Height + szFormulaire.Height;
                Size = newSizeThis;
                m_panelFormulaire.Size = szFormulaire;

                m_btnAnnuler.Visible = m_actionFormulaire.CanCancel;
                this.Text            = m_actionFormulaire.Descriptif;
                dialogResult         = ShowDialog(CTimosApp.Navigateur);
                if (dialogResult == DialogResult.OK)
                {
                    CResultAErreur resultTmp = createur.MAJ_Champs();
                    if (!resultTmp)
                    {
                        CFormAlerte.Afficher(resultTmp.Erreur);
                        bBoucle = true;
                    }
                }
            }
            result.Data = C2iDialogResult.Get2iDialogResultFromDialogResult(dialogResult);
            return(result);
        }