예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BaseObject"/> class.
        /// </summary>
        /// <param name="sOrigUrl">The original URL.</param>
        /// <param name="sPathToFile">The path to file.</param>
        /// <param name="sFileName">Name of the file.</param>
        /// <param name="sFileExtension">The file extension.</param>
        /// <param name="sContentType">Type of the content.</param>
        /// <param name="oRequestMsg">The request message.</param>
        /// <param name="listCookieInformation">The list cookie information.</param>
        public BaseObject(
            string sOrigUrl,
            string sPathToFile,
            string sFileName,
            string sFileExtension,
            string sContentType,
            HTTPMsg oRequestMsg,
            List <string> listCookieInformation)
        {
            this.RequestMessage = oRequestMsg;
            this.OriginalUrl    = sOrigUrl;
            this.PathToFileName = sPathToFile;
            this.FileName       = sFileName;
            this.FileExtension  = sFileExtension;
            this.ContentType    = sContentType;

            this.Referrer    = ObjectParser.ParseReferer((HttpRequestHeader)oRequestMsg.HTTPHeader);
            this.HostAddress = ObjectParser.ParseHostAddress((HttpRequestHeader)oRequestMsg.HTTPHeader);

            this.Content      = oRequestMsg.PairMessages[0].HTTPContent.Content;
            this.TimeStamp    = oRequestMsg.TimeStamp;
            this.ExportSource = oRequestMsg.ExportSources[0];

            this.CookieInformation = listCookieInformation;
            this.UniqueHash        = ComputeHash.GetMd5Hash(this.Content);


            this.FileSize            = this.Content.LongLength;
            this.ListOfNewReferences = new List <string>();
        }
예제 #2
0
        /// <summary>
        /// Compresses each archive part and construct index.rdf file with webpage base metadata.
        /// </summary>
        /// <param name="oZipArchive">The parent zip archive.</param>
        /// <param name="oTimeStamp">The time stamp of parent archive.</param>
        /// <param name="sExportDirectory">The export directory.</param>
        /// <param name="iPartPosition">The position of archive part.</param>
        public void CompressArchivePart(ZipArchive oZipArchive, DateTime oTimeStamp, string sExportDirectory, int iPartPosition)
        {
            // INDEX RDF
            var sRdfData = "<?xml version=\"1.0\"?>\n" +
                           "       <RDF:RDF xmlns:MAF=\"http://maf.mozdev.org/metadata/rdf#\"\n" +
                           "       xmlns:NC=\"http://netfox.fit.vutbr.cz/About.en.cshtml\"\n" +
                           "       xmlns:RDF=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n" +
                           "  <RDF:Description RDF:about=\"urn:root\">\n" +
                           "    <MAF:originalurl RDF:resource=\"" + "http://" + this.ParentObject.HostAddress + "/\"/>\n" +
                           "    <MAF:title RDF:resource=\"" + this.ParentObject.GetTitle() + "\"/>\n" +
                           "    <MAF:archivetime RDF:resource=\"" + DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Local).ToString("dd.MM.yyyy hh: mm:ss tt") + "\"/>\n" +
                           "    <MAF:indexfilename RDF:resource=\"index.html\"/>\n" +
                           "    <MAF:charset RDF:resource=\"" + this.ParentObject.GetCharSet() + "\"/>\n" +
                           "  </RDF:Description>\n" +
                           "</RDF:RDF>";

            // END INDEX RDF

            //Do zip comprimation
            this.BaseFolder = ComputeHash.GetMd5Hash(oTimeStamp.Ticks + this.ParentObject.HostAddress + this.ParentObject.GetCharSet() + this.ExportListOfArchiveObjects.Count + iPartPosition);

            //RDF WRITE
            var rdfEntry            = oZipArchive.CreateEntry(this.BaseFolder + "/" + "index.rdf");
            var rdfEntryWriteStream = new BinaryWriter(rdfEntry.Open());

            rdfEntryWriteStream.Write(Encoding.GetEncoding(437).GetBytes(sRdfData));
            rdfEntryWriteStream.Dispose();
            //END RDF WRITE

            foreach (var oItemToArchive in this.ExportListOfArchiveObjects)
            {
                if (!(oItemToArchive is ParentObject))
                {
                    oItemToArchive.FileName = "index_files/" + oItemToArchive.FileName;
                    if (oItemToArchive is TextObject)
                    {
                        ((TextObject)oItemToArchive).ProcessReferences();
                    }
                }
                else
                {
                    ((ParentObject)oItemToArchive).ProcessReferences();
                }

                oItemToArchive.SaveObjectContent(oZipArchive, sExportDirectory, this.BaseFolder);
            }
        }
예제 #3
0
 /// <summary>
 /// Initialization of archive compressing and constructing compressed file.
 /// </summary>
 private void CompressInitialize()
 {
     this.ArchiveName      = this._oParentObject.HostAddress + "_" + ComputeHash.GetMd5Hash(this._oParentObject.HostAddress + this._oParentObject.TimeStamp.Ticks) + ".maff";
     this._fsZipFileStream = new FileStream(this.ExportDirectory + @"\" + this.ArchiveName, FileMode.Create);
     this._zipArchive      = new ZipArchive(this._fsZipFileStream, ZipArchiveMode.Update);
 }