Ejemplo n.º 1
0
        private void RecursiveCreateXML(Mediachase.IBN.Business.ControlSystem.FileStorage fs, XmlNode currParent, int FolderID, bool bIncludeAsset, int DeepLevel, int CurDeepLevel, int AssetId)
        {
            Mediachase.IBN.Business.ControlSystem.DirectoryInfo[] infos = fs.GetDirectories(FolderID);
            foreach (Mediachase.IBN.Business.ControlSystem.DirectoryInfo info in infos)
            {
                XmlNode folderItem = InsertFolderInformation(fs, currParent, info, info.Name, AssetId);

                if (folderItem != null)
                {
                    if (DeepLevel <= 0 || DeepLevel > (CurDeepLevel + 1))
                    {
                        XmlNode childFolderItemNode = folderItem.SelectSingleNode("ChildList");

                        RecursiveCreateXML(fs, childFolderItemNode, info.Id, bIncludeAsset, DeepLevel, CurDeepLevel + 1, AssetId);
                    }
                }
            }
            if (bIncludeAsset)
            {
                Mediachase.IBN.Business.ControlSystem.FileInfo[] files = fs.GetFiles(FolderID);
                foreach (Mediachase.IBN.Business.ControlSystem.FileInfo file in files)
                {
                    InsertAssetInformation(currParent, FolderID, file);
                }
            }
        }
Ejemplo n.º 2
0
        internal static Pop3Message Create(string From, string[] To, string Subject, string Body, Mediachase.IBN.Business.ControlSystem.DirectoryInfo Attachments)
        {
            MemoryStream emlMessage = new MemoryStream();
            byte[] tmpBuffer = null;

            string ToEmail = string.Join(", ", To);

            #region Fill Pop3 Message Stream
            // Create Pop3 Message Headers
            StringBuilder sbHeaders = new StringBuilder();

            sbHeaders.AppendFormat("Date: {0}", DateTime.UtcNow.ToString("r")).Append("\r\n");

            sbHeaders.AppendFormat("From: {0}", Rfc822HeaderCollection.Encode2AsciiString(From)).Append("\r\n");
            sbHeaders.AppendFormat("To: {0}", Rfc822HeaderCollection.Encode2AsciiString(ToEmail)).Append("\r\n");

            sbHeaders.AppendFormat("Subject: {0}", Rfc822HeaderCollection.Encode2AsciiString(Subject)).Append("\r\n");
            sbHeaders.Append("MIME-Version: 1.0").Append("\r\n");
            sbHeaders.Append("Content-Type: multipart/mixed; boundary=\"----------7E143249668A83E\"").Append("\r\n");
            sbHeaders.Append("\r\n");

            tmpBuffer = Encoding.ASCII.GetBytes(sbHeaders.ToString());
            emlMessage.Write(tmpBuffer, 0, tmpBuffer.Length);

            // Create Pop3 Message Entry
            StringBuilder sbMessage = new StringBuilder();

            sbMessage.Append("------------7E143249668A83E").Append("\r\n");

            // IF MESSAGE IS PLAIN TEXT
            //sbMessage.Append("Content-Type: text/plain; charset=utf-8").Append("\r\n");

            // IF MESSAGE IS HTML TEXT
            sbMessage.Append("Content-Type: text/html; charset=utf-8").Append("\r\n");

            sbMessage.Append("Content-Transfer-Encoding: base64").Append("\r\n");
            sbMessage.Append("\r\n");

            string FullMessage = Body;

            sbMessage.Append(Convert.ToBase64String(Encoding.UTF8.GetBytes(FullMessage),Base64FormattingOptions.InsertLineBreaks)).Append("\r\n");

            tmpBuffer = Encoding.ASCII.GetBytes(sbMessage.ToString());
            emlMessage.Write(tmpBuffer, 0, tmpBuffer.Length);

            if (Attachments != null)
            {
                Hashtable contentTypeHash = new Hashtable();

                using (IDataReader reader = ContentType.GetListContentTypes())
                {
                    while (reader.Read())
                    {
                        contentTypeHash.Add(((string)reader["Extension"]).ToLower(), (string)reader["ContentTypeString"]);
                    }
                }

                // Add Pop3 Message Attachements
                foreach (Mediachase.IBN.Business.ControlSystem.FileInfo fileInfo in Attachments.GetFiles())
                {
                    StringBuilder sbFile = new StringBuilder();

                    sbFile.Append("------------7E143249668A83E").Append("\r\n");
                    sbFile.AppendFormat("Content-Type: {0}; name=\"{1}\"", fileInfo.FileBinaryContentType, Rfc822HeaderCollection.Encode2AsciiString(fileInfo.Name)).Append("\r\n");
                    sbFile.Append("Content-Transfer-Encoding: base64").Append("\r\n");
                    sbFile.AppendFormat("Content-Disposition: attachment; filename=\"{0}\"", Rfc822HeaderCollection.Encode2AsciiString(fileInfo.Name)).Append("\r\n");
                    sbFile.Append("\r\n");

                    using (MemoryStream fs = new MemoryStream())
                    {
                        FileStorage.LightLoadFile(fileInfo, fs);
                        fs.Capacity = (int)fs.Length;

                        sbFile.Append(Convert.ToBase64String(fs.GetBuffer(), Base64FormattingOptions.InsertLineBreaks));
                    }

                    sbFile.Append("\r\n");

                    tmpBuffer = Encoding.ASCII.GetBytes(sbFile.ToString());
                    emlMessage.Write(tmpBuffer, 0, tmpBuffer.Length);
                }
            }

            // Add Final Line
            tmpBuffer = Encoding.ASCII.GetBytes("------------7E143249668A83E--\r\n\r\n");
            emlMessage.Write(tmpBuffer, 0, tmpBuffer.Length);

            #endregion

            return new Pop3Message(emlMessage);
        }