public static UploadDocumentGroup GetUploadDocumentGroup(XmlDocumentGroup xmlDocumentGroup, string zipPath)
        {
            var docArray = File.ReadAllBytes(zipPath);

            UploadDocumentGroup uploadDocumentGroup = new UploadDocumentGroup();
            uploadDocumentGroup.Data = docArray;
            XmlSerializer serializer = new XmlSerializer(typeof(XmlDocumentGroup));
            using (TextWriter writer = new StringWriter())
            {
                serializer.Serialize(writer, xmlDocumentGroup);
                uploadDocumentGroup.MetaInfo = writer.ToString();
            }

            return uploadDocumentGroup;
        }
        private void AddNewDocumentGroup(
            XmlDocumentGroup xmlDocumentGroup,
            UploadDocumentGroup uploadDocumentGroup,
            Dictionary<string, MemoryStream> documentsData)
        {
            DocumentGroup newDocumentGroup = new DocumentGroup();
            newDocumentGroup.CrawlerId = this.db.GetOrCreateCrawlerId(xmlDocumentGroup.Crawler);
            newDocumentGroup.Identifier = xmlDocumentGroup.Identifier;
            newDocumentGroup.DocumentGroupName = xmlDocumentGroup.FileName;
            newDocumentGroup.DocumentGroupFormat = xmlDocumentGroup.Format;
            newDocumentGroup.Lang = xmlDocumentGroup.Lang;
            newDocumentGroup.Operation = (int)xmlDocumentGroup.Operation;
            newDocumentGroup.DocumentGroupDate = xmlDocumentGroup.Date;

            // Byte Array Data
            newDocumentGroup.DataContent = uploadDocumentGroup.Data;

            List<Document> documents = this.AddDocuments(xmlDocumentGroup.Document, documentsData);
            foreach (Document document in documents)
            {
                newDocumentGroup.Documents.Add(document);
            }

            this.db.AddDocumentGroup(newDocumentGroup);
        }
        private void UpdateDeleteDocumentGroup(
            XmlDocumentGroup xmlDocumentGroup,
            UploadDocumentGroup uploadDocumentGroup,
            Dictionary<string, MemoryStream> documentsData,
            string documentGroupIdentifier)
        {
            // Delete
            this.db.DeleteDocumentGroup(documentGroupIdentifier);

            // Update
            if (xmlDocumentGroup.Operation == Operation.Upd)
            {
                this.AddNewDocumentGroup(xmlDocumentGroup, uploadDocumentGroup, documentsData);
            }
        }
        private XmlDocumentGroup GetNewXmlDocumentGroup(DocumentGroup documentGroupDb)
        {
            XmlDocumentGroup xmlDocumentGroup = new XmlDocumentGroup();
            xmlDocumentGroup.Crawler = Arguments.CrawlerName;
            xmlDocumentGroup.Date = documentGroupDb.DocumentGroupDate;
            xmlDocumentGroup.FileName = documentGroupDb.DocumentGroupName;
            xmlDocumentGroup.Format = "application/zip";
            xmlDocumentGroup.Identifier = documentGroupDb.Identifier;
            xmlDocumentGroup.Lang = Arguments.Language;
            xmlDocumentGroup.Operation = (Operation)documentGroupDb.Operation;

            foreach (var documentDb in documentGroupDb.Documents)
            {
                XmlDocumentMetaInfo xmlDocumentMetaInfo = new XmlDocumentMetaInfo();
                xmlDocumentMetaInfo.File = documentDb.DocumentName;
                xmlDocumentMetaInfo.Format = documentDb.DocumentFormat;
                xmlDocumentMetaInfo.Identifier = documentDb.Identifier;
                xmlDocumentMetaInfo.Md5 = documentDb.Md5;
                xmlDocumentMetaInfo.Operation = (Operation)documentDb.Operation;
                xmlDocumentMetaInfo.Url = documentDb.Url;

                xmlDocumentGroup.Document.Add(xmlDocumentMetaInfo);
            }

            return xmlDocumentGroup;
        }