Exemplo n.º 1
0
 /// <summary>
 /// Deprecated Method for adding a new object to the TreetyMetadatas EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToTreetyMetadatas(TreetyMetadata treetyMetadata)
 {
     base.AddObject("TreetyMetadatas", treetyMetadata);
 }
Exemplo n.º 2
0
 /// <summary>
 /// Create a new TreetyMetadata object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="hostCountryId">Initial value of the HostCountryId property.</param>
 /// <param name="partnerCountryId">Initial value of the PartnerCountryId property.</param>
 /// <param name="fileTypeName">Initial value of the FileTypeName property.</param>
 public static TreetyMetadata CreateTreetyMetadata(global::System.Int32 id, global::System.Int32 hostCountryId, global::System.Int32 partnerCountryId, global::System.String fileTypeName)
 {
     TreetyMetadata treetyMetadata = new TreetyMetadata();
     treetyMetadata.Id = id;
     treetyMetadata.HostCountryId = hostCountryId;
     treetyMetadata.PartnerCountryId = partnerCountryId;
     treetyMetadata.FileTypeName = fileTypeName;
     return treetyMetadata;
 }
Exemplo n.º 3
0
        private void UpdateConceptAndArticle(UnitOfWork work, DataRow row, TreetyMetadata treatyMetadata, List<PublisherStatus> publisherStatus)
        {
            //var concept = GetConcept(treatyMetadata, row);
            //Add To DB

            //var article = GetArticle(treatyMetadata, row);

            var treatyArticleConceptMetadata = GetArticleConceptMetadata(treatyMetadata, row);

            var repository = RepositoryContainer.GetRepository<TreetyArticleMetadata>(work);
            var dbTacMetadata =
                repository.Filter(
                    c => c.TreetyMetadataId == treatyMetadata.Id &&
                         c.ConceptId == treatyArticleConceptMetadata.ConceptId &&
                         c.ArticleId == treatyArticleConceptMetadata.ArticleId).FirstOrDefault();

            if (dbTacMetadata == null)
            {
                //Add To DB
                if (string.IsNullOrWhiteSpace(treatyArticleConceptMetadata.ArticleId))
                {
                    if(!string.IsNullOrWhiteSpace(treatyArticleConceptMetadata.ConceptId))
                    {
                        publisherStatus.Add(new PublisherStatus()
                        {
                            Status = false,
                            Message = string.Format("Article ID not found for Concept [{0}]", treatyArticleConceptMetadata.Concept)
                        });
                    }

                }
                else
                {
                    repository.Add(treatyArticleConceptMetadata);
                }

            }
            else
            {
                //Update
                dbTacMetadata.ArticleContent = treatyArticleConceptMetadata.ArticleContent;
                dbTacMetadata.ArticleNo = treatyArticleConceptMetadata.ArticleNo;
                dbTacMetadata.ArticleTitle = treatyArticleConceptMetadata.ArticleTitle;
                dbTacMetadata.Concept = treatyArticleConceptMetadata.Concept;
            }
        }
Exemplo n.º 4
0
        private void RetriveTreatyMetadata(string sheetName, TreetyMetadata treatyMetadata, DataRowCollection rows,
                                           List<PublisherStatus> publisherStatus)
        {
            int rowStartCount = Convert.ToInt32(ConfigurationManager.AppSettings["ExcelRowStartIndex"]);

            var hostCountryCode = rows[rowStartCount].ItemArray[1].ToString();
            var hostCountry = _countries.FirstOrDefault(c => c.Code == hostCountryCode);

            if (hostCountry == null)
            {
                publisherStatus.Add(new PublisherStatus
                    {
                        Status = false,
                        Message = string.Format("Host Country Code not found in sheet {0}.", sheetName)
                    });
            }

            var partnerCountryCode = rows[rowStartCount + 2].ItemArray[1].ToString();
            var partnerCountry = _countries.FirstOrDefault(c => c.Code == partnerCountryCode);

            if (partnerCountry == null)
            {
                publisherStatus.Add(new PublisherStatus
                    {
                        Status = false,
                        Message = string.Format("Partner Country Code not found in sheet {0}.", sheetName)
                    });
            }
            if (hostCountry != null && partnerCountry != null)
            {
                var countryPair = TreatyCountryPair.GetPairCountries(hostCountry.Id, partnerCountry.Id, _countries);
                treatyMetadata.HostCountryId = countryPair[0].Id;
                treatyMetadata.PartnerCountryId = countryPair[1].Id;
            }
            var forceUpdate = rows[rowStartCount].ItemArray[3].ToString().Trim().ToLower() == "forceupdate";
            if (CanPublishTreatyData(treatyMetadata.HostCountryId, treatyMetadata.PartnerCountryId, forceUpdate) == false)
            {
                publisherStatus.Add(new PublisherStatus
                {
                    Status = false,
                    Message = string.Format("This data will not published as already published for this countries.Ref Sheet {0}.", sheetName)
                });
            }

            treatyMetadata.Title = rows[rowStartCount + 3].ItemArray[1].ToString();

            treatyMetadata.Title = GetSentenceCase(treatyMetadata.Title);

            treatyMetadata.TitleId = rows[rowStartCount + 3].ItemArray[2].ToString();
            if (string.IsNullOrWhiteSpace(treatyMetadata.TitleId))
            {
                publisherStatus.Add(new PublisherStatus
                    {
                        Status = false,
                        Message = string.Format("WARNING! Treaty already exist for this country pair, look in sheet {0}. Use ForceUpdate to update new data.", sheetName)
                    });
                return;
            }

            byte[] treatyPdf = GetTreatyPdfData(rows[rowStartCount + 3].ItemArray[3].ToString(), publisherStatus, sheetName);
            if (treatyPdf != null && treatyPdf.Length > 0)
            {
                treatyMetadata.TreatyPdf = treatyPdf;
            }
            treatyMetadata.FileTypeName = "pdf";

            treatyMetadata.TreatyLink = rows[rowStartCount + 3].ItemArray[4].ToString().Trim();
            treatyMetadata.Status = rows[rowStartCount + 5].ItemArray[0].ToString().Trim();
            treatyMetadata.Negotiation = rows[rowStartCount + 5].ItemArray[1].ToString().Trim();
            treatyMetadata.Signature = rows[rowStartCount + 5].ItemArray[2].ToString().Trim();
            treatyMetadata.Adoption = rows[rowStartCount + 5].ItemArray[3].ToString().Trim();
            treatyMetadata.MfnClauses = rows[rowStartCount + 5].ItemArray[4].ToString().Trim();
            treatyMetadata.Ratification = rows[rowStartCount + 5].ItemArray[5].ToString().Trim();
            treatyMetadata.EffectiveDate = rows[rowStartCount + 5].ItemArray[6].ToString().Trim();
            treatyMetadata.EntryIntoForce = rows[rowStartCount + 5].ItemArray[7].ToString().Trim();
            treatyMetadata.Reservations = rows[rowStartCount + 5].ItemArray[8].ToString().Trim();
            treatyMetadata.Derogations = rows[rowStartCount + 5].ItemArray[9].ToString().Trim();
            treatyMetadata.Denunciations = rows[rowStartCount + 5].ItemArray[10].ToString().Trim();
            treatyMetadata.AccessionAdherence = rows[rowStartCount + 5].ItemArray[11].ToString().Trim();
            treatyMetadata.Interpretations = rows[rowStartCount + 5].ItemArray[12].ToString().Trim();
            treatyMetadata.AmendmentProtocol = rows[rowStartCount + 5].ItemArray[13].ToString().Trim();
            treatyMetadata.Note = rows[rowStartCount + 5].ItemArray[14].ToString().Trim();
            treatyMetadata.DomesticApplication = rows[rowStartCount + 7].ItemArray[0].ToString();
        }
Exemplo n.º 5
0
 private TreetyArticleMetadata GetArticleConceptMetadata(TreetyMetadata treatyMetadata, DataRow row)
 {
     var tacMetadata = new DataAccess.TreetyArticleMetadata();
     tacMetadata.Concept = row.ItemArray[0].ToString();
     tacMetadata.ConceptId = row.ItemArray[1].ToString();
     tacMetadata.TreetyMetadataId = treatyMetadata.Id;
     tacMetadata.ArticleNo = row.ItemArray[2].ToString();
     tacMetadata.ArticleTitle = row.ItemArray[3].ToString();
     tacMetadata.ArticleContent = row.ItemArray[4].ToString();
     tacMetadata.ArticleId = row.ItemArray[5].ToString();
     return tacMetadata;
 }
Exemplo n.º 6
0
        private static void UpdateTreatyMetadata(TreetyMetadata treatyMetadata, TreetyMetadata metadata)
        {
            metadata.Title = treatyMetadata.Title;
            metadata.TitleId = treatyMetadata.TitleId;
            metadata.Status = treatyMetadata.Status;
            metadata.Negotiation = treatyMetadata.Negotiation;
            metadata.Signature = treatyMetadata.Signature;
            metadata.Adoption = treatyMetadata.Adoption;
            metadata.MfnClauses = treatyMetadata.MfnClauses;
            metadata.Ratification = treatyMetadata.Ratification;

            metadata.EffectiveDate = treatyMetadata.EffectiveDate;
            metadata.EntryIntoForce = treatyMetadata.EntryIntoForce;

            if (treatyMetadata.TreatyPdf != null && treatyMetadata.TreatyPdf.Length > 0)
            {
                metadata.TreatyPdf = treatyMetadata.TreatyPdf;
            }

            metadata.Reservations = treatyMetadata.Reservations;
            metadata.Derogations = treatyMetadata.Derogations;
            metadata.Denunciations = treatyMetadata.Denunciations;
            metadata.AccessionAdherence = treatyMetadata.AccessionAdherence;
            metadata.Interpretations = treatyMetadata.Interpretations;
            metadata.AmendmentProtocol = treatyMetadata.AmendmentProtocol;
            metadata.TreatyLink = treatyMetadata.TreatyLink;
        }