Exemplo n.º 1
0
        static public _Recordset GetRecordsetFromXml(string xml)
        {
            _Stream stream = null;

            try
            {
                stream = new ADODB.Stream();
                stream.Open(Missing.Value, ConnectModeEnum.adModeUnknown, StreamOpenOptionsEnum.adOpenStreamUnspecified, "", "");
                stream.WriteText(xml, StreamWriteEnum.adWriteChar);
                stream.Position = 0;

                var recordset = new Recordset();
                recordset.Open(stream, Missing.Value, CursorTypeEnum.adOpenUnspecified, LockTypeEnum.adLockUnspecified, 0);
                return(recordset);
            }
            catch (Exception ex)
            {
                ErrorLog.LogError(ex, new CallingMethod());
                return(default(_Recordset));
            }
            finally
            {
                if (stream != null)
                {
                    Marshal.ReleaseComObject(stream);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Save Picture to DB
        /// </summary>
        /// <param name="rsFields">Data row</param>
        /// <param name="sFileName">File name</param>
        /// <returns>True or false</returns>
        private dynamic SavePictureToDb(DataRow rsFields, string sFileName)
        {
            bool returnValue = false;

            ADODB.Stream strStream = new ADODB.Stream();

            try
            {
                if (!File.Exists(sFileName))
                {
                    return(false);
                }

                strStream = new ADODB.Stream {
                    Type = StreamTypeEnum.adTypeBinary
                };
                strStream.Open();
                strStream.LoadFromFile(sFileName);

                rsFields["Signature"] = strStream.Read();

                returnValue = true;
            }
            catch (Exception)
            {
                // ignored
            }
            finally
            {
                strStream.Close();
            }
            return(returnValue);
        }
Exemplo n.º 3
0
 public EML()
 {
     msg = new CDO.Message();
     stm = new ADODB.Stream();
     stm.Open(System.Reflection.Missing.Value,
              ADODB.ConnectModeEnum.adModeUnknown,
              ADODB.StreamOpenOptionsEnum.adOpenStreamUnspecified,
              "", "");
     stm.Type = ADODB.StreamTypeEnum.adTypeBinary;
 }
Exemplo n.º 4
0
        //Useless -> NON ho idea di come usarla correttamente
        public static Message ReadMessage(string emlFileName)
        {
            Message msg = new Message();

            ADODB.Stream stream = new ADODB.Stream();
            stream.Open(Type.Missing, ConnectModeEnum.adModeUnknown, StreamOpenOptionsEnum.adOpenStreamUnspecified, string.Empty, string.Empty);
            stream.LoadFromFile(emlFileName);
            stream.Flush();
            msg.DataSource.OpenObject(stream, "_Stream");
            msg.DataSource.Save();
            return(msg);
        }
Exemplo n.º 5
0
 private CDO.Message GetMessage(FileInfo fileInfo)
 {
     CDO.Message  msg    = new CDO.Message();
     ADODB.Stream stream = new ADODB.Stream();
     stream.Type = StreamTypeEnum.adTypeBinary;
     stream.Open(Type.Missing, ADODB.ConnectModeEnum.adModeUnknown, ADODB.StreamOpenOptionsEnum.adOpenStreamUnspecified, String.Empty, String.Empty);
     stream.LoadFromFile(fileInfo.FullName);
     stream.Flush();
     msg.DataSource.OpenObject(stream, "_Stream");
     msg.DataSource.Save();
     return(msg);
 }