Пример #1
0
 /// <summary>
 /// Create a new Country object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="regionId">Initial value of the RegionId property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 public static Country CreateCountry(global::System.Int32 id, global::System.Int32 regionId, global::System.String name)
 {
     Country country = new Country();
     country.Id = id;
     country.RegionId = regionId;
     country.Name = name;
     return country;
 }
Пример #2
0
        private IEnumerable<PublisherStatus> PublishContent(DataRowCollection contentRows, string sheetName)
        {
            var allStatus = new List<PublisherStatus>();
            if (contentRows.Count >= 1)
            {

                using (var work = new UnitOfWork())
                {
                    var countryRepo = RepositoryContainer.GetRepository<Nest.DataAccess.Country>(work);
                    var tpTreatyRepo = RepositoryContainer.GetRepository<Nest.DataAccess.TpTreaty>(work);
                    var allCountries = countryRepo.All().ToList();
                    var dbHostCountry = allCountries.FirstOrDefault(b => b.Name == contentRows[0].ItemArray[0].ToString().Trim());
                    var removeCountryList = tpTreatyRepo.Delete(b => b.HostCountryId == dbHostCountry.Id);
                    var metaInfo = contentRows[0];
                    if(dbHostCountry == null)
                    {
                        allStatus.Add(new PublisherStatus() { Message = "Host Country Name Doesn't Exist In DataBase" ,Status = false});
                        allStatus.Add(new PublisherStatus
                        {
                            Status = false,
                            Message = "Data uploading failed for sheet " + sheetName
                        });
                        return allStatus;
                    }
                    //var conceptIdExistStatus = CheckConceptIdInfo(contentRows);
                    //var idExistStatus =  conceptIdExistStatus.ToList();
                    //allStatus.AddRange(idExistStatus);
                    //if (idExistStatus.Any(b => b.Status == false))
                    //{
                    //    allStatus.Add(new PublisherStatus
                    //    {
                    //        Status = false,
                    //        Message = "Data uploading failed for sheet " + sheetName
                    //    });
                    //    return allStatus;
                    //}
                    HostCountry = dbHostCountry;
                    if (contentRows.Count >= 2)
                    {
                        for (var index = 1; index < contentRows.Count; index++)
                        {
                            if(string.IsNullOrEmpty(contentRows[index].ItemArray[0].ToString().Trim()))continue;
                            var dbPartenerCountry = allCountries.FirstOrDefault(b => b.Name == contentRows[index].ItemArray[0].ToString().Trim());
                            if (dbPartenerCountry == null)
                            {
                                allStatus.Add(new PublisherStatus() { Message = "Partner Country Name " + contentRows[index].ItemArray[0].ToString().Trim() + " Doesn't Exist In DataBase", Status = false });
                            }
                            if (dbPartenerCountry != null)
                            {
                                var dbTpTreaty = tpTreatyRepo.Filter(b => b.HostCountryId == dbHostCountry.Id && b.PartnerCountryId == dbPartenerCountry.Id).FirstOrDefault();
                                if (dbTpTreaty == null)
                                {
                                    dbTpTreaty = new Nest.DataAccess.TpTreaty();
                                    tpTreatyRepo.Add(dbTpTreaty);
                                }
                                dbTpTreaty.HostCountryId = dbHostCountry.Id;
                                dbTpTreaty.PartnerCountryId = dbPartenerCountry.Id;
                                dbTpTreaty.OcdeArt1 = contentRows[index].ItemArray[1].ToString().Trim().Equals("None", StringComparison.InvariantCultureIgnoreCase) ? null : contentRows[index].ItemArray[1].ToString().Trim();
                                dbTpTreaty.OcdeArt2 = contentRows[index].ItemArray[2].ToString().Trim().Equals("None", StringComparison.InvariantCultureIgnoreCase) ? null : contentRows[index].ItemArray[2].ToString().Trim();
                                dbTpTreaty.ReliefFromDouble = contentRows[index].ItemArray[3].ToString().Trim().Equals("None", StringComparison.InvariantCultureIgnoreCase) ? null : contentRows[index].ItemArray[3].ToString().Trim();
                                dbTpTreaty.CompetentAuthority = contentRows[index].ItemArray[4].ToString().Trim().Equals("None", StringComparison.InvariantCultureIgnoreCase) ? null : contentRows[index].ItemArray[4].ToString().Trim();
                                dbTpTreaty.OcdeArt3 = contentRows[index].ItemArray[5].ToString().Trim().Equals("None", StringComparison.InvariantCultureIgnoreCase) ? null : contentRows[index].ItemArray[5].ToString().Trim();
                                dbTpTreaty.OcdeArt1_ConceptId = contentRows[index].ItemArray[1].ToString().Trim().Length > 0 && contentRows[index].ItemArray[1].ToString().Trim().ToLower() != "None".ToLower() ? metaInfo.ItemArray[1].ToString().Trim() : null;
                                dbTpTreaty.OcdeArt2_ConceptId = contentRows[index].ItemArray[2].ToString().Trim().Length > 0 && contentRows[index].ItemArray[2].ToString().Trim().ToLower() != "None".ToLower() ? metaInfo.ItemArray[2].ToString().Trim() : null;
                                dbTpTreaty.ReliefFromDouble_ConceptId = contentRows[index].ItemArray[3].ToString().Trim().Length > 0 && contentRows[index].ItemArray[3].ToString().Trim().ToLower() != "None".ToLower() ? metaInfo.ItemArray[3].ToString().Trim() : null;
                                dbTpTreaty.CompetentAuthority_ConceptId = contentRows[index].ItemArray[4].ToString().Trim().Length > 0 && contentRows[index].ItemArray[4].ToString().Trim().ToLower() != "None".ToLower() ? metaInfo.ItemArray[4].ToString().Trim() : null;
                                dbTpTreaty.OcdeArt3_ConceptId = contentRows[index].ItemArray[5].ToString().Trim().Length > 0 && contentRows[index].ItemArray[5].ToString().Trim().ToLower() != "None".ToLower() ? metaInfo.ItemArray[5].ToString().Trim() : null;
                            }

                        }
                        if(allStatus.Any(b => b.Status == false) == false)
                        {
                            work.SaveChanges();
                            allStatus.Add(new PublisherStatus() { Message = "Data uploaded sucessfully for sheet " + sheetName ,Status = true});
                        }
                        else
                        {
                            allStatus.Add(new PublisherStatus
                            {
                                Status = false,
                                Message = "Data uploading failed for sheet " + sheetName
                            });
                        }
                    }
                }
            }
            return allStatus;
        }
Пример #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Countries EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToCountries(Country country)
 {
     base.AddObject("Countries", country);
 }
Пример #4
0
        private void InitializeMemberData(string sheetName, UnitOfWork work, List<PublisherStatus> publisherStatus)
        {
            _hostCountry = GetHostCountry(sheetName);
            if (_hostCountry == null)
            {
                publisherStatus.Add(new PublisherStatus
                {
                    Status = false,
                    Message = string.Format("Host country not found for sheet {0}.", sheetName)
                });
                return;
            }
            _treetyIds =
                RepositoryContainer.GetRepository<TreetyMetadata>(work).Filter(b => b.HostCountryId == _hostCountry.Id || b.PartnerCountryId == _hostCountry.Id).ToList();

            if (_treetyIds == null)
            {
                publisherStatus.Add(new PublisherStatus
                {
                    Status = false,
                    Message = string.Format("No Treaty available for sheet {0}.", sheetName)
                });
                return;
            }

            var query =
                @"select TRM.ArticleId,TM.hostCountryId AS HostCountryId,TM.partnerCountryId AS PartnerCountryId from dbo.TreetyMetadata TM join dbo.TreetyArticleMetadata TRM  on TM.Id = TRM.TreetyMetadataId where TM.HostCountryId = " +
                _hostCountry.Id.ToString(CultureInfo.InvariantCulture) + "OR TM.PartnerCountryId = " + _hostCountry.Id.ToString(CultureInfo.InvariantCulture);
            _articleIds = work.UnityDbContext.ExecuteStoreQuery<ArticleMetaData>(query).ToList();
            _allStreams = RepositoryContainer.GetRepository<Stream>(work).All().ToList();
        }