/// <summary> /// Serialize information for crowled document to XMl and upload document and XML to Web Service /// </summary> /// <param name="documentGroupDb"></param> public bool UploadToService(DocumentGroup documentGroupDb) { try { string docPath = Arguments.DestinationFolder + "\\Data\\" + documentGroupDb.DocumentGroupName; var docArray = File.ReadAllBytes(docPath); UploadDocumentGroup uploadDocumentGroup = new UploadDocumentGroup(); uploadDocumentGroup.Data = docArray; XmlDocumentGroup xmlDocumentGroup = this.GetNewXmlDocumentGroup(documentGroupDb); XmlSerializer serializer = new XmlSerializer(typeof(XmlDocumentGroup)); using (TextWriter writer = new StringWriter()) { serializer.Serialize(writer, xmlDocumentGroup); uploadDocumentGroup.MetaInfo = writer.ToString(); } string msg = this.webService.UploadFile(uploadDocumentGroup); if (msg != "Ok") { CrawlerLog.LogInfo("Service Upload Error DocumentGroupId: " + documentGroupDb.DocumentGroupId + "Error:" + msg); return false; } } catch (Exception ex) { CrawlerLog.LogException(ex); return false; } return true; }
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; }