public DocumentCommon(DocumentCommon documentCommon) { if (documentCommon == null) { throw new ArgumentException(TextResources.IssuDocument_Core_Exception_MissingArgument_DocumentCommon_Message, "documentCommon"); } this.DocumentId = documentCommon.DocumentId; this.DocumentName = documentCommon.DocumentName; this.OrgDocName = documentCommon.OrgDocName; this.PublishDate = documentCommon.PublishDate; }
/// <summary> /// Create embed for documents without embeds to have an dataConfigId (embed). /// </summary> /// <param name="document"> /// Common documents for embed. /// </param> /// <returns> /// The <see cref="DocumentEmbed"/>. /// </returns> private DocumentEmbed CreateEmbedForDocument(DocumentCommon document) { // prepare parameters Dictionary<RequestParameters.RequestParamters, string> paramDict = new Dictionary<RequestParameters.RequestParamters, string> { { RequestParameters.RequestParamters.action, IssuuAddActionParameterValue }, { RequestParameters.RequestParamters.apiKey, _issuuConfig.APIKey }, { RequestParameters.RequestParamters.documentId, document.DocumentId }, { RequestParameters.RequestParamters.readerStartPage, "1" }, { RequestParameters.RequestParamters.width, Width.ToString(CultureInfo.InvariantCulture) }, { RequestParameters.RequestParamters.height, Height.ToString(CultureInfo.InvariantCulture) }, }; // build request string response = DoHttpRequest(paramDict); // parse xml to get data XDocument parsedDoc = XDocument.Parse(response); IEnumerable<XElement> docsElements = parsedDoc.Descendants("rsp").Descendants("documentEmbed"); // dictionary with embedId as key,and documents as value,in this case,there should be only one documentEmbed foreach (XElement docsElement in docsElements) { // existing documents string docId = docsElement.Attribute("documentId") != null ? docsElement.Attribute("documentId").Value : null; if (docId == null) { continue; } DocumentEmbed docEmbed = new DocumentEmbed(document); docEmbed.EmbedId = docsElement.Attribute("id").Value; docEmbed.Height = docsElement.Attribute("height").Value; docEmbed.Width = docsElement.Attribute("width").Value; docEmbed.Created = docsElement.Attribute("created").Value; docEmbed.DataConfigId = docsElement.Attribute("dataConfigId").Value; return docEmbed; } return null; }