Beispiel #1
0
        /// /////////////////////////////////////////////////////////
        public void CommitFinders()
        {
            List <CAgentFinderFromKey> lstFinders = AgentFinderList;

            CContexteDonnee.ChangeRowSansDetectionModification(Row.Row, c_champCacheAgentFinders, DBNull.Value);
            CDonneeBinaireInRow data = DataAgentFinders;

            if (lstFinders == null)
            {
                data.Donnees = null;
            }
            else
            {
                MemoryStream stream = new MemoryStream();
                try
                {
                    BinaryWriter           writer = new BinaryWriter(stream);
                    CSerializerSaveBinaire ser    = new CSerializerSaveBinaire(writer);
                    CResultAErreur         result = ser.TraiteListe <CAgentFinderFromKey>(lstFinders);
                    data.Donnees = stream.GetBuffer();
                    writer.Close();
                }
                catch
                {
                    data.Donnees = null;
                }
                stream.Close();
            }
            DataAgentFinders = data;
        }
Beispiel #2
0
        /// /////////////////////////////////////////////////////////
        public void CommitParametresHotelPolling()
        {
            List <CSnmpHotelPollingSetup> lstParametres = ParametresHotelPollingList;

            CContexteDonnee.ChangeRowSansDetectionModification(Row.Row, c_champCacheParametresHotelPolling, DBNull.Value);
            CDonneeBinaireInRow data = DataParametresHotelPolling;

            if (lstParametres == null)
            {
                data.Donnees = null;
            }
            else
            {
                MemoryStream stream = new MemoryStream();
                try
                {
                    BinaryWriter           writer = new BinaryWriter(stream);
                    CSerializerSaveBinaire ser    = new CSerializerSaveBinaire(writer);
                    CResultAErreur         result = ser.TraiteListe <CSnmpHotelPollingSetup>(lstParametres);
                    data.Donnees = stream.GetBuffer();
                    writer.Close();
                }
                catch
                {
                    data.Donnees = null;
                }
                stream.Close();
            }
            DataParametresHotelPolling = data;
        }
        //--------------------------------------------------------------------------
        public static void SetFormule(int nIdSession, string strKey, C2iExpression formule)
        {
            AssureRecepteurNotifications(nIdSession);
            CDataBaseRegistrePourClient reg = new CDataBaseRegistrePourClient(nIdSession);

            if (formule == null)
            {
                reg.SetValeurBlob("GLOBFOR_" + strKey, null);
            }
            else
            {
                MemoryStream           stream = new MemoryStream();
                BinaryWriter           writer = new BinaryWriter(stream);
                CSerializerSaveBinaire ser    = new CSerializerSaveBinaire(writer);
                CResultAErreur         res    = ser.TraiteObject <C2iExpression>(ref formule);
                if (res)
                {
                    reg.SetValeurBlob("GLOBFOR_" + strKey, stream.GetBuffer());
                    CDonneeNotificationResetCacheDatabaseRegistre notif = new CDonneeNotificationResetCacheDatabaseRegistre(nIdSession);
                    CEnvoyeurNotification.EnvoieNotifications(new IDonneeNotification[] { notif });
                }
                writer.Close();
                stream.Close();
                stream.Dispose();
            }
        }
Beispiel #4
0
 /// <summary>
 /// Mutualise l'affectation des formules
 /// </summary>
 /// <param name="strChampCache"></param>
 /// <param name="data"></param>
 /// <param name="formule"></param>
 private void SetFormule(string strChampCache, ref CDonneeBinaireInRow data, C2iExpression formule)
 {
     CContexteDonnee.ChangeRowSansDetectionModification(Row.Row, strChampCache, DBNull.Value);
     if (formule == null)
     {
         data.Donnees = null;
     }
     else
     {
         MemoryStream stream = new MemoryStream();
         try
         {
             BinaryWriter           writer = new BinaryWriter(stream);
             CSerializerSaveBinaire ser    = new CSerializerSaveBinaire(writer);
             CResultAErreur         result = ser.TraiteObject <C2iExpression>(ref formule);
             data.Donnees = stream.GetBuffer();
             writer.Close();
         }
         catch
         {
             data.Donnees = null;
         }
         stream.Close();
     }
 }
Beispiel #5
0
        public static void StockValeur(
            DataRow row,
            int idSession,
            string strChampType,
            string strChampBlob,
            string strChampString,
            object val)
        {
            if (val is IDifferencesBlob)
            {
                MemoryStream           stream     = new MemoryStream();
                BinaryWriter           writer     = new BinaryWriter(stream);
                CSerializerSaveBinaire serializer = new CSerializerSaveBinaire(writer);
                I2iSerializable        serTmp     = (I2iSerializable)val;
                CResultAErreur         result     = serializer.TraiteObject(ref serTmp);
                if (!result)
                {
                    throw new Exception(I.T("Can not serialize blob differences|192"));
                }
                row[strChampType] = typeof(IDifferencesBlob).ToString();
                CDonneeBinaireInRow donnee = new CDonneeBinaireInRow(idSession, row, strChampBlob);
                donnee.Donnees    = stream.GetBuffer();
                row[strChampBlob] = donnee;

                writer.Close();
                stream.Close();
            }
            else if (val is byte[])
            {
                CDonneeBinaireInRow donnee = new CDonneeBinaireInRow(idSession, row, strChampBlob);
                donnee.Donnees    = (byte[])val;
                row[strChampBlob] = donnee;
                row[strChampType] = typeof(byte[]).ToString();
            }
            else if (val != null && val.GetType() == typeof(CDonneeBinaireInRow))
            {
                row[strChampBlob] = val;
                row[strChampType] = typeof(byte[]).ToString();
            }
            else if (val is CObjetDonneeAIdNumerique)
            {
                row[strChampString] = ((CObjetDonneeAIdNumerique)val).Id;
                row[strChampString] = val.GetType().ToString();
            }
            else
            {
                row[strChampString] = CUtilTexte.ToUniversalString(val);
                if (val != null)
                {
                    row[strChampType] = val.GetType().ToString();
                }
                //else
                //    row[strChampType] = "";
            }
        }
Beispiel #6
0
        /// ////////////////////////////////////////////////////////
        public byte[] GetDataSerialisationFormulairePourClient()
        {
            System.IO.MemoryStream stream     = new System.IO.MemoryStream();
            System.IO.BinaryWriter writer     = new System.IO.BinaryWriter(stream);
            CSerializerSaveBinaire serializer = new CSerializerSaveBinaire(writer);
            I2iSerializable        ser        = m_formulaire;

            serializer.TraiteObject(ref ser);
            byte[] buffer = stream.GetBuffer();
            writer.Close();
            stream.Close();
            return(buffer);
        }
 private void m_btnCopy_Click(object sender, EventArgs e)
 {
     if (m_blocFormulaire != null)
     {
         MemoryStream           stream = new MemoryStream();
         BinaryWriter           writer = new BinaryWriter(stream);
         CSerializerSaveBinaire ser    = new CSerializerSaveBinaire(writer);
         CResultAErreur         result = ser.TraiteObject <CBlocWorkflowFormulaire>(ref m_blocFormulaire);
         if (result)
         {
             Clipboard.SetData(typeof(CBlocWorkflowFormulaire).ToString(), stream.GetBuffer());
         }
         stream.Close();
         writer.Close();
         stream.Dispose();
     }
 }
        private void m_btnCopy_Click(object sender, EventArgs e)
        {
            List <CFormuleNommee> lst = new List <CFormuleNommee>();

            lst.AddRange(GetFormules());
            MemoryStream           stream = new MemoryStream();
            BinaryWriter           writer = new BinaryWriter(stream);
            CSerializerSaveBinaire ser    = new CSerializerSaveBinaire(writer);
            CResultAErreur         result = ser.TraiteListe <CFormuleNommee>(lst);

            if (result)
            {
                Clipboard.SetData(typeof(List <CFormuleNommee>).ToString(), stream.GetBuffer());
            }
            stream.Close();
            writer.Close();
            stream.Dispose();
        }
Beispiel #9
0
        //--------------------------------------------------------------------------------------
        public static CResultAErreur SaveInstance()
        {
            CResultAErreur result = CResultAErreur.True;

            if (m_dictionnaire != null)
            {
                MemoryStream           flux       = new MemoryStream();
                BinaryWriter           writer     = new BinaryWriter(flux);
                CSerializerSaveBinaire serilaizer = new CSerializerSaveBinaire(writer);
                result = serilaizer.TraiteObject <CDictionnaireTypeEditeTypeFormPrefere>(ref m_dictionnaire);
                if (result)
                {
                    CDataBaseRegistrePourClient registre = new CDataBaseRegistrePourClient(CSc2iWin32DataClient.ContexteCourant.IdSession);
                    result = registre.SetValeurBlob(c_cleRegistre, flux.ToArray());
                }
                writer.Close();
                flux.Close();
            }
            return(result);
        }
        //------------------------------------------------------------------------------
        //Le data du result contient un byte[] correspondant à la valeur sérializée
        public static CResultAErreur WriteValeur(
            object valeur,
            IVariableDynamique variable,
            CContexteDonnee contexte)
        {
            MemoryStream           stream     = new MemoryStream();
            BinaryWriter           writer     = new BinaryWriter(stream);
            CSerializerSaveBinaire serializer = new CSerializerSaveBinaire(writer);
            CResultAErreur         result     = CSerializerValeursVariables.SerializeValeurVariable(
                ref valeur,
                variable,
                serializer, contexte);

            writer.Close();
            if (result)
            {
                result.Data = stream.ToArray();
            }
            stream.Close();
            return(result);
        }
        /// ////////////////////////////////////////
        protected virtual CResultAErreur VerifieDonneesAndMAJSiIlFaut()
        {
            MemoryStream stream    = new MemoryStream();
            BinaryWriter binWriter = new BinaryWriter(stream);

            sc2i.common.CSerializerSaveBinaire saver = new CSerializerSaveBinaire(binWriter);

            CResultAErreur result = ObjetEdite.Serialize(saver);
            //NE se sérialise pas, surement un nouvel objet
            bool bSansFilet = !result.Result;

            result = CResultAErreur.True;
            try
            {
                result = MAJ_Champs();
                if (result)
                {
                    result = ObjetEdite.VerifieDonnees();
                }
            }
            catch (Exception e)
            {
                result.EmpileErreur(new CErreurException(e));
            }
            if (!result)
            {
                if (!bSansFilet)
                {
                    stream.Seek(0, SeekOrigin.Begin);
                    BinaryReader           binReader = new BinaryReader(stream);
                    CSerializerReadBinaire reader    = new CSerializerReadBinaire(binReader);
                    ObjetEdite.Serialize(reader);
                    binReader.Close();
                }
            }
            binWriter.Close();
            stream.Close();
            return(result);
        }
        //------------------------------------------------------
        private static void SetSetupForWindow(CSessionClient session, Form form, CSetupVisibiliteControles setup)
        {
            string strKey = c_racineCleRegistre + form.GetType().ToString();
            CDataBaseRegistrePourClient reg = new CDataBaseRegistrePourClient(session.IdSession);

            if (setup == null)
            {
                reg.SetValeurBlob(strKey, new byte[0]);
            }
            else
            {
                MemoryStream           stream = new MemoryStream();
                BinaryWriter           writer = new BinaryWriter(stream);
                CSerializerSaveBinaire ser    = new CSerializerSaveBinaire(writer);
                CResultAErreur         result = setup.Serialize(ser);
                stream.Flush();
                reg.SetValeurBlob(strKey, stream.GetBuffer());
                writer.Close();
                stream.Close();
                stream.Dispose();
            }
        }
Beispiel #13
0
        //--------------------------------------------
        public void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            if (m_entite == null)
            {
                info.AddValue(c_cleDataSerialize, new byte[0]);
            }
            else
            {
                MemoryStream           stream     = new MemoryStream();
                BinaryWriter           writer     = new BinaryWriter(stream);
                CSerializerSaveBinaire serializer = new CSerializerSaveBinaire(writer);
                CResultAErreur         result     = serializer.TraiteObject <CEntiteDeMemoryDb>(ref m_entite);
                writer.Close();
                stream.Close();
                if (!result)
                {
                    throw new Exception(result.Erreur.ToString());
                }

                info.AddValue(c_cleDataSerialize, stream.GetBuffer());
            }
        }
Beispiel #14
0
        //------------------------------------------------
        public static CEasyQueryAvecSource FromQuery(CEasyQuery query)
        {
            CEasyQueryAvecSource qas = new CEasyQueryAvecSource();

            byte[] data = null;
            using (MemoryStream stream = new MemoryStream())
            {
                using (BinaryWriter writer = new BinaryWriter(stream))
                {
                    CSerializerSaveBinaire ser = new CSerializerSaveBinaire(writer);
                    CResultAErreur         res = query.Serialize(ser);

                    data = stream.GetBuffer();
                    writer.Close();
                    writer.Dispose();
                    if (!res)
                    {
                        return(null);
                    }
                }
            }
            using (MemoryStream stream = new MemoryStream(data))
            {
                using (BinaryReader reader = new BinaryReader(stream))
                {
                    CSerializerReadBinaire ser = new CSerializerReadBinaire(reader);
                    CResultAErreur         res = qas.BaseSerialize(ser);
                    qas.Sources = query.Sources;
                    reader.Close();
                    stream.Close();
                    if (!res)
                    {
                        return(null);
                    }
                }
            }
            return(qas);
        }
        public static CResultAErreur Copy(I2iSerializable objet, string strSignatureFichier)
        {
            CResultAErreur result = CResultAErreur.True;

            if (objet == null)
            {
                result.EmpileErreur(I.T("Nothing to copy|30048"));
                return(result);
            }
            MemoryStream           stream     = new MemoryStream();
            BinaryWriter           writer     = new BinaryWriter(stream);
            CSerializerSaveBinaire serializer = new CSerializerSaveBinaire(writer);

            result = serializer.TraiteObject(ref objet);
            if (result)
            {
                DataObject data = new DataObject(strSignatureFichier, stream.GetBuffer());
                Clipboard.SetDataObject(data);
            }
            writer.Close();
            stream.Close();
            return(result);
        }
Beispiel #16
0
        //----------------------------------------------------------------------------------
        public CResultAErreur SaveToFile(string strNomFichier)
        {
            CResultAErreur result = CResultAErreur.True;
            FileStream     stream = null;

            try
            {
                stream = new FileStream(strNomFichier, FileMode.Create, FileAccess.Write, FileShare.None);
            }
            catch (Exception e)
            {
                result.EmpileErreur(new CErreurException(e));
                result.EmpileErreur(I.T("Error while opening the file|109"));
            }
            try
            {
                BinaryWriter writer = new BinaryWriter(stream);
                writer.Write(c_idFichier);
                CSerializerSaveBinaire serializer = new CSerializerSaveBinaire(writer);
                result = Serialize(serializer);
                writer.Close();
            }
            catch (Exception e)
            {
                result.EmpileErreur(new CErreurException(e));
                result.EmpileErreur(I.T("Error while writing the file|112"));
            }
            finally
            {
                try
                {
                    stream.Close();
                }
                catch {}
            }
            return(result);
        }
Beispiel #17
0
        //------------------------------------------------
        public CEasyQuery GetEasyQuerySansSource()
        {
            CEasyQuery qss = new CEasyQuery();

            byte[] data = null;
            using (MemoryStream stream = new MemoryStream())
            {
                using (BinaryWriter writer = new BinaryWriter(stream))
                {
                    CSerializerSaveBinaire ser = new CSerializerSaveBinaire(writer);
                    CResultAErreur         res = BaseSerialize(ser);
                    data = stream.GetBuffer();
                    writer.Close();
                    writer.Dispose();
                    if (!res)
                    {
                        return(null);
                    }
                }
            }
            using (MemoryStream stream = new MemoryStream(data))
            {
                using (BinaryReader reader = new BinaryReader(stream))
                {
                    CSerializerReadBinaire ser = new CSerializerReadBinaire(reader);
                    CResultAErreur         res = qss.Serialize(ser);
                    qss.Sources = Sources;
                    reader.Close();
                    stream.Close();
                    if (!res)
                    {
                        return(null);
                    }
                }
            }
            return(qss);
        }
Beispiel #18
0
        public void CommitListPlages()
        {
            List <CPlageIP> listePlages = PlagesIP;

            CContexteDonnee.ChangeRowSansDetectionModification(Row.Row, c_champCacheListePlages, DBNull.Value);
            CDonneeBinaireInRow data = DataListePlagesIp;

            if (listePlages == null)
            {
                data.Donnees      = null;
                DataListePlagesIp = data;
            }
            else
            {
                MemoryStream stream = new MemoryStream();
                try
                {
                    BinaryWriter           writer     = new BinaryWriter(stream);
                    CSerializerSaveBinaire serializer = new CSerializerSaveBinaire(writer);
                    CResultAErreur         result     = serializer.TraiteListe <CPlageIP>(listePlages);
                    writer.Close();
                    if (result)
                    {
                        data.Donnees = stream.GetBuffer();
                    }
                }
                catch
                {
                    data.Donnees = null;
                }
                finally
                {
                    stream.Close();
                }
                DataListePlagesIp = data;
            }
        }